Skip to content

Instantly share code, notes, and snippets.

@herskinduk
Created October 6, 2015 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herskinduk/d39b23e24843ba66e5eb to your computer and use it in GitHub Desktop.
Save herskinduk/d39b23e24843ba66e5eb to your computer and use it in GitHub Desktop.
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
//use OpenId
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = ...,
Authority = ...,
PostLogoutRedirectUri = "/",
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = context =>
{
context.HandleResponse();
context.Response.Redirect("/Error?message=" + context.Exception.Message);
return Task.FromResult(0);
},
SecurityTokenValidated = context =>
{
WriteTokenExipreTime(context.AuthenticationTicket.Properties.ExpiresUtc);
// Login with Sitecore here.
// Also map claims
return Task.FromResult(0);
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment