It would be useful to expose the OAuth2Introspections events (OnCreatingTicket and OnAuthenticationFailed) in the IdentityServerAuthenticationOptions.
This would then follow the same pattern as allowing the JwtBearerEvents to be exposed.
Use Cases:
Enriching claims on the created ClaimsPrincipal
Logging the events for failure and creation
Notes:
I have heard of people saying that a middleware can be used to enrich the claims but the middleware after "UseAuthentication", all execute before the ClaimsIdentity is created, therefore the only option after that is using an ActionFilter to augment the claims. The Authentication handlers only execute when that scheme is called upon when it reaches the MVC middleware, which is too late.
My project has 2 schemes.
Presumed Code Changes:
public class IdentityServerAuthenticationOptions : AuthenticationSchemeOptions
{
Other code removed for brevity...
/// <summary>
/// Events for IntrospectionEvents
/// </summary>
public OAuth2IntrospectionEvents IntrospectionEvents { get; set; } = new OAuth2IntrospectionEvents();
internal void ConfigureIntrospection(OAuth2IntrospectionOptions introspectionOptions)
{
Other Code removed for brevity
introspectionOptions.Events = new OAuth2IntrospectionEvents
{
OnAuthenticationFailed = e => IntrospectionEvents.OnAuthenticationFailed(e),
OnCreatingTicket = e => IntrospectionEvents.OnCreatingTicket(e)
};
}
}
Hi,
It would be useful to expose the OAuth2Introspections events (OnCreatingTicket and OnAuthenticationFailed) in the IdentityServerAuthenticationOptions. This would then follow the same pattern as allowing the JwtBearerEvents to be exposed.
Use Cases:
Notes: I have heard of people saying that a middleware can be used to enrich the claims but the middleware after "UseAuthentication", all execute before the ClaimsIdentity is created, therefore the only option after that is using an ActionFilter to augment the claims. The Authentication handlers only execute when that scheme is called upon when it reaches the MVC middleware, which is too late. My project has 2 schemes.
Presumed Code Changes:
Many thanks