{"id":11339,"date":"2016-02-29T14:29:46","date_gmt":"2016-02-29T19:29:46","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=11339"},"modified":"2016-03-01T11:30:59","modified_gmt":"2016-03-01T16:30:59","slug":"use-thinktecture-embeddedsts-in-asp-net-web-project","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=11339","title":{"rendered":"Use Thinktecture EmbeddedSTS in ASP.NET Web Project"},"content":{"rendered":"<div class='toc wptoc'>\n<h2>Contents<\/h2>\n<ol class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#Create_Test_Web_Application\">Create Test Web Application<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Config_Web.config_File\">Config Web.config File<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Install_EmbeddedSTS\">Install EmbeddedSTS<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Test\">Test<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#Config_Users_and_Claims\">Config Users and Claims<\/a>\n\t<\/li>\n\t<li>\n\t\t<a href=\"#References\">References<\/a>\n\t<\/li>\n<\/ol>\n<\/ol>\n<\/div>\n<div class='wptoc-end'>&nbsp;<\/div>\n<span id=\"Create_Test_Web_Application\"><h2>Create Test Web Application<\/h2><\/span>\n<p>* Open Visual Studio 2013<br \/>\n* Create a new ASP.NET web project, e.g. a web form project named <strong>TestEmbeddedSTSWeb<\/strong><br \/>\n* Change project authentication to <em>No Authentication<\/em><\/p>\n<span id=\"\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/02\/embeddedSTS_createWebProj_1.jpg\" rel=\"attachment wp-att-11340\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/02\/embeddedSTS_createWebProj_1-300x238.jpg\" alt=\"embeddedSTS_createWebProj_1\" width=\"300\" height=\"238\" class=\"aligncenter size-medium wp-image-11340\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/02\/embeddedSTS_createWebProj_1-300x238.jpg 300w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/02\/embeddedSTS_createWebProj_1.jpg 762w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/h6><\/span>\n<p>* Add to project references:<br \/>\n&#8211; <em>System.IdentityModel<\/em><br \/>\n&#8211; <em>System.identitymodel.services<\/em><\/p>\n<span id=\"Config_Web.config_File\"><h2>Config Web.config File<\/h2><\/span>\n<p>* Add configSections<\/p>\n<pre lang=\"xml\">\r\n<configSections>\r\n  <section name=\"system.identityModel\" type=\"System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\" \/>\r\n  <section name=\"system.identityModel.services\" type=\"System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089\" \/>\r\n<\/configSections>\r\n<\/pre>\n<p>* Add Http Modules config:<\/p>\n<pre lang=\"xml\">\r\n<system.webServer>\r\n  <modules>\r\n    <add name=\"SessionAuthenticationModule\" type=\"System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" preCondition=\"managedHandler\" \/>\r\n    <add name=\"WSFederationAuthenticationModule\" type=\"System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" preCondition=\"managedHandler\" \/>\r\n  <\/modules>\r\n<\/system.webServer>\r\n<\/pre>\n<p>* Add to &lt;system.web&gt; section:<\/p>\n<pre lang=\"xml\">\r\n    <authorization>\r\n      <deny users=\"?\" \/>\r\n    <\/authorization>\r\n<\/pre>\n<p>* Setup federation configuration to point to embedded STS:<\/p>\n<pre lang=\"xml\">\r\n  <system.identityModel.services>\r\n    <federationConfiguration>\r\n      <wsFederation \r\n        passiveRedirectEnabled=\"true\" \r\n        issuer=\"http:\/\/EmbeddedSts\" \r\n        realm=\"http:\/\/localhost:52834\/TestEmbeddedSTSWeb\/\" \r\n        requireHttps=\"false\" \/>\r\n      <cookieHandler requireSsl=\"false\" \/>\r\n    <\/federationConfiguration>\r\n  <\/system.identityModel.services>\r\n<\/pre>\n<p>* Note project specific port number, i.e. <strong>52834<\/strong><\/p>\n<span id=\"Install_EmbeddedSTS\"><h2>Install EmbeddedSTS<\/h2><\/span>\n<p>* Install from <a href=\"http:\/\/www.nuget.org\/packages\/Thinktecture.IdentityModel.EmbeddedSts\">NuGet<\/a>:<\/p>\n<pre lang=\"bash\">\r\nInstall-Package Thinktecture.IdentityModel.EmbeddedSts \r\n<\/pre>\n<span id=\"_1\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/02\/embeddedSTS_install_NuGet_1.jpg\" rel=\"attachment wp-att-11341\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/02\/embeddedSTS_install_NuGet_1-300x53.jpg\" alt=\"embeddedSTS_install_NuGet_1\" width=\"300\" height=\"53\" class=\"aligncenter size-medium wp-image-11341\" srcset=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/02\/embeddedSTS_install_NuGet_1-300x53.jpg 300w, https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/02\/embeddedSTS_install_NuGet_1.jpg 732w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/h6><\/span>\n<span id=\"Test\"><h2>Test<\/h2><\/span>\n<p>* Debug default page.<br \/>\n* You should be redirected to sign in page from embedded STS:<br \/>\n* Sign in:<\/p>\n<span id=\"_2\"><h6><a href=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/02\/embeddedSTS_signIn_1.jpg\" rel=\"attachment wp-att-11342\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/jianmingli.com\/wp\/wp-content\/uploads\/2016\/02\/embeddedSTS_signIn_1.jpg\" alt=\"embeddedSTS_signIn_1\" width=\"174\" height=\"115\" class=\"aligncenter size-full wp-image-11342\" \/><\/a><\/h6><\/span>\n<p>* Normal page shown.<\/p>\n<span id=\"Config_Users_and_Claims\"><h2>Config Users and Claims<\/h2><\/span>\n<p>* Users and claims are contained in <em>App_Data\/<strong>EmbeddedStsUsers.json<\/strong><\/em> file.<br \/>\n* The file will be created if it does not exist.<br \/>\n* You can edit the file to add users and customize claims.<\/p>\n<span id=\"References\"><h2>References<\/h2><\/span>\n<p>* <a href=\"http:\/\/brockallen.com\/2013\/10\/22\/announcing-thinktecture-embeddedsts-a-simple-local-sts-for-asp-net-applications\/\">Announcement<\/a><br \/>\n* <a href=\"https:\/\/github.com\/IdentityModel\/Thinktecture.IdentityModel\/wiki\/EmbeddedSts\">EmbeddedSts<\/a><br \/>\n* <a href=\"http:\/\/stackoverflow.com\/questions\/21246757\/vs2013-mvc-4-how-to-setup-thinktecture-embedded-sts\">http:\/\/stackoverflow.com\/questions\/21246757\/vs2013-mvc-4-how-to-setup-thinktecture-embedded-sts<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create Test Web Application * Open Visual Studio 2013 * Create a new ASP.NET web project, e.g. a web form project named TestEmbeddedSTSWeb * Change project authentication to No Authentication * Add to project references: &#8211; System.IdentityModel &#8211; System.identitymodel.services Config &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=11339\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[119,679],"tags":[672,673],"class_list":["post-11339","post","type-post","status-publish","format-standard","hentry","category-saml","category-wif","tag-sts","tag-wif"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-2WT","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/11339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11339"}],"version-history":[{"count":2,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/11339\/revisions"}],"predecessor-version":[{"id":11344,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/11339\/revisions\/11344"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}