Created
October 6, 2015 09:22
-
-
Save herskinduk/0d4dc5bf1d7c05189ccc to your computer and use it in GitHub Desktop.
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
app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType); | |
app.UseCookieAuthentication( | |
new CookieAuthenticationOptions | |
{ | |
AuthenticationType = | |
WsFederationAuthenticationDefaults.AuthenticationType | |
}); | |
app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions | |
{ | |
MetadataAddress = ..., | |
Wtrealm = ..., | |
Notifications = new WsFederationAuthenticationNotifications | |
{ | |
AuthenticationFailed = context => | |
{ | |
context.HandleResponse(); | |
context.Response.Redirect("/Error?message=" + context.Exception.Message); | |
return Task.FromResult(0); | |
}, | |
SecurityTokenValidated = context => | |
{ | |
if (HttpContext.Current != null) | |
{ | |
WriteTokenExipreTime(context.AuthenticationTicket.Properties.ExpiresUtc); | |
// Login here | |
// Map claims | |
} | |
return Task.FromResult(0); | |
}, | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment