Skip to content

Instantly share code, notes, and snippets.

@phillipsj
Created March 10, 2015 14:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save phillipsj/3200ddda158eddac74ca to your computer and use it in GitHub Desktop.
Example
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = _authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications()
{
SecurityTokenValidated = (context) =>
{
// retriever caller data from the incoming principal
var username = context.AuthenticationTicket.Identity.FindFirst(ClaimTypes.Name).Value.Split('@')[0];
var database = DependencyResolver.Current.GetService(typeof (IDatabase)) as IDatabase;
var employee = database.Query(new GetEmployeeByUsername(username));
if (employee == null)
{
throw new SecurityTokenValidationException();
}
// I add my custom claims here
};
context.AuthenticationTicket.Identity.AddClaims(claims);
return Task.FromResult(0);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment