Use Thinktecture EmbeddedSTS in ASP.NET Web Project

 

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

embeddedSTS_createWebProj_1

* Add to project references:
System.IdentityModel
System.identitymodel.services

Config Web.config File

* Add configSections

<configSections>
  <section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
  <section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</configSections>

* Add Http Modules config:

<system.webServer>
  <modules>
    <add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
    <add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
  </modules>
</system.webServer>

* Add to <system.web> section:

    <authorization>
      <deny users="?" />
    </authorization>

* Setup federation configuration to point to embedded STS:

  <system.identityModel.services>
    <federationConfiguration>
      <wsFederation 
        passiveRedirectEnabled="true" 
        issuer="http://EmbeddedSts" 
        realm="http://localhost:52834/TestEmbeddedSTSWeb/" 
        requireHttps="false" />
      <cookieHandler requireSsl="false" />
    </federationConfiguration>
  </system.identityModel.services>

* Note project specific port number, i.e. 52834

Install EmbeddedSTS

* Install from NuGet:

Install-Package Thinktecture.IdentityModel.EmbeddedSts
embeddedSTS_install_NuGet_1

Test

* Debug default page.
* You should be redirected to sign in page from embedded STS:
* Sign in:

embeddedSTS_signIn_1

* Normal page shown.

Config Users and Claims

* Users and claims are contained in App_Data/EmbeddedStsUsers.json file.
* The file will be created if it does not exist.
* You can edit the file to add users and customize claims.

References

* Announcement
* EmbeddedSts
* http://stackoverflow.com/questions/21246757/vs2013-mvc-4-how-to-setup-thinktecture-embedded-sts

This entry was posted in saml, WIF and tagged , . Bookmark the permalink.

One Response to Use Thinktecture EmbeddedSTS in ASP.NET Web Project

Leave a Reply

Your email address will not be published. Required fields are marked *


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.