Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuthenticationSchemeOptions.EventsType not supported by AddIdentityServerAuthentication #109

Closed
Giorgi opened this issue Jan 4, 2019 · 9 comments

Comments

Projects
None yet
2 participants
@Giorgi
Copy link

commented Jan 4, 2019

Issue / Steps to reproduce the problem

I am using IdentityServer4.AccessTokenValidation to validate jwt tokens and I wanted to log various JwtBearerEvents events. I noticed that if I set options.JwtBearerEvents = new LoggingBearerEvents(); the overriden methods in my class get called but if I set options.EventsType = typeof(LoggingBearerEvents); the methods do not get called.

On the other hand if I replace AddIdentityServerAuthentication with AddJwtBearer everything works fine even if I set it using options.EventsType = typeof(LoggingBearerEvents);

Is this scenario not supported by IdentityServer4.AccessTokenValidation or is this a bug ?

@Giorgi

This comment has been minimized.

Copy link
Author

commented Jan 4, 2019

I enabled logging but it doesn't output any relevant information.

@brockallen brockallen transferred this issue from IdentityServer/IdentityServer4 Jan 4, 2019

@Giorgi

This comment has been minimized.

Copy link
Author

commented Jan 5, 2019

@brockallen I think you need to set it on jwtOptions instance inside ConfigureJwtBearer method

@Giorgi

This comment has been minimized.

Copy link
Author

commented Jan 6, 2019

I added jwtOptions.EventsType = EventsType; to the ConfigureJwtBearer method and the events get fired but it causes MessageReceivedContext.Token to be empty in MessageReceived method as the InternalTokenRetriever isn't executed any more.

@leastprivilege

This comment has been minimized.

Copy link
Member

commented Jan 7, 2019

Yep there are issues as you found out. It's not supported right now.

@Giorgi

This comment has been minimized.

Copy link
Author

commented Jan 7, 2019

@leastprivilege That's a pity because EventsType is the only way to get another class injected in custom event handler.

@leastprivilege

This comment has been minimized.

Copy link
Member

commented Jan 7, 2019

you can retrieve the token yourself from the HttpContext. Then it would work.

@leastprivilege

This comment has been minimized.

Copy link
Member

commented Jan 7, 2019

What's the reason you are using our handler?

@Giorgi

This comment has been minimized.

Copy link
Author

commented Jan 7, 2019

To be honest I think I can just use the Microsoft JWT handler but I think it would be nice if EventsType was supported.

@leastprivilege

This comment has been minimized.

Copy link
Member

commented Jan 8, 2019

Either that or implement MessageReceived accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.