Skip to content

Instantly share code, notes, and snippets.

@herskinduk
Created October 6, 2015 09:22
Show Gist options
  • Save herskinduk/0d4dc5bf1d7c05189ccc to your computer and use it in GitHub Desktop.
Save herskinduk/0d4dc5bf1d7c05189ccc to your computer and use it in GitHub Desktop.
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