-
Notifications
You must be signed in to change notification settings - Fork 90
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
How do you add an extra claim? #198
Comments
I've been searching for a subtle way to implement this, but this turns out to be a bit challenging. The Something like a |
Late reply, but I encountered the same challenge when trying to add custom claims to the JWT generated by this bundle. As you suggested, dispatching an event before the token is finalized seems like the most appropriate way to introduce a hook without significantly altering the core logic. I came up with a potential solution by introducing a new BEFORE_JWT_TOKEN_BUILD event. It might not be the perfect approach, so feel free to share your thoughts. Here’s how it works:
Let me know if you see any downsides or potential improvements. |
I get a working JWT token, but I want to add extra data to it:
I've found
Lcobucci\JWT\Builder::withClaim
in the code which seems exactly what I need, but there is no way for my to apply it. For some reason everything is final, so I can't apply the Open/Closed principle anywhere. I'm not looking to rewrite half this tool, I just need a small hook to add a little data.OAuth2Events
) dont offer anything useful.final
anyway.final
final
)$customClaims
which could be picked up in the AccessTokenTrait again.Is there a reason this is so hard? I dont mind creating some code to implement this, but I'd like to know if that is worth my time.
The text was updated successfully, but these errors were encountered: