Thursday, May 14, 2015

Visual Studio : No STS tool

Inspired by this question on stackoverflow regarding the missing STS tool in VS 2013:

Add sts reference missing in visual studio 2013 update 4

From my answer:

"FedUtil and the "Identity and Access Tool" are no longer available.

The only way to do this is via "Change Authentication" when you create the project and then select "On Premise". Unfortunately, you can only do this when you create the project. You can't retrofit it afterwards. I believe this is changing in VS 2015.

Part of the reason for the tools disappearing is that these tools were WIF based whereas OWIN is the basis for all new VS development.

You can merge the WIF section from the web.config of an old WIF project"

So how do you do the last part.

Create a new project in VS 2013 - I choose MVC - and under "Change Authentication" select "No authentication".

Now find a VS2012 project of yours that uses WIF - with .NET 4.5

Use something like WinMerge and merge the two web.config.

Copy these over:

<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>


<system.web>
    <authentication mode="None" />
    <authorization>
      <deny users="?" />
    </authorization>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
  </system.web>


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

as well as the "ida:" lines under appSettings

and the entire system.identitymodel and system.identitymodel.services sections.

Obviously you need to update the URL of your target application .( I assume your IDP and certificates are still the same and are still valid otherwise you need to update them as well).

Add References to:

  • System.IdentityModel
  • System.IdentityModel.Selectors
  • System.IdentityModel.services

Add a NuGet package from Package Manager:

Install-Package System.IdentityModel.Tokens.ValidatingIssuerNameRegistry -Version 4.5.0

and you are done.

Enjoy!

1 comment:

imediadesigns said...

Thanks For This Great Article.
Keep up This Great Sites.