Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use OWIN Ws-Federation package to authenticate against ADFS 3.0

I have an MVC intranet site that needs to use AD accounts for authentication.

I setup ADFS 3.0 (Win Server 2012 R2) and followed this to setup the ADFS Relying Party Trust.

This other post introduces the Ws-Federation OWIN components and I'd like to use it. It mentions how to connect to an Azure AD but nothing regarding ADFS.

I tried setting the configuration properties "MetadataAddress" and "Wtrealm" to match what I configured in ADFS but at runtime I get an error:

A default value for SignInAsAuthenticationType was not found in IAppBuilder Properties. 
This can happen if your authentication middleware are added in the wrong order, or if one is missing.

I am looking for the proper way remove this error

like image 631
oscarmorasu Avatar asked Apr 24 '14 07:04

oscarmorasu


1 Answers

Yeah.. I came across the same issue. Just do the following and it should work:

    app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType );

    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
       AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType
    });
like image 105
LyphTEC Avatar answered Oct 13 '22 12:10

LyphTEC