This week I lost some time searching where I could specify the ‘Home Realm’ when using the WIF components inside OWIN.
I finally found it and decided to share the code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class Startup | |
{ | |
public void Configuration(IAppBuilder app) | |
{ | |
ConfigureAuth(app); | |
} | |
public void ConfigureAuth(IAppBuilder app) | |
{ | |
app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType); | |
app.UseCookieAuthentication( | |
new CookieAuthenticationOptions | |
{ | |
AuthenticationType = | |
WsFederationAuthenticationDefaults.AuthenticationType | |
}); | |
app.UseWsFederationAuthentication( | |
new WsFederationAuthenticationOptions | |
{ | |
MetadataAddress = "https://adfs2.ordina.be/federationmetadata/2007-06/federationmetadata.xml", | |
Wtrealm = "https://localhost/Web.IAM/", | |
Notifications = new WsFederationAuthenticationNotifications | |
{ | |
RedirectToIdentityProvider = (context) => | |
{ | |
context.ProtocolMessage.Whr = "https://adfs2.ordina.be/adfs/services/trust/"; | |
return Task.FromResult(0); | |
} | |
} | |
}); | |
} | |
} |