Skip to content

Instantly share code, notes, and snippets.

@conwid
Last active May 24, 2023 20:13
Show Gist options
  • Save conwid/bfcef34c9763977cc079982b4f9f1a99 to your computer and use it in GitHub Desktop.
Save conwid/bfcef34c9763977cc079982b4f9f1a99 to your computer and use it in GitHub Desktop.
Demo showing how to hook up custom callbacks for token creation and validation.
public class CustomAuthenticationEvents : CookieAuthenticationEvents
{
public override async Task SigningIn(CookieSigningInContext context)
{
await base.SigningIn(context);
}
public async override Task SigningOut(CookieSigningOutContext context)
{
await base.SigningOut(context);
}
public override async Task ValidatePrincipal(CookieValidatePrincipalContext context)
{
//context.RejectPrincipal();
//context.ReplacePrincipal();
await base.ValidatePrincipal(context);
}
}
builder.Services.AddOptions<CookieAuthenticationOptions>(IdentityConstants.ApplicationScheme)
.Configure<ITicketStore>((options, store) => options.SessionStore = store)
.Configure<CookieAuthenticationEvents>((options, events) => options.Events = events);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment