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

Is there an easy way to add custom data to the JWT payloads? #226

Open
pkly opened this issue Aug 17, 2020 · 2 comments
Open

Is there an easy way to add custom data to the JWT payloads? #226

pkly opened this issue Aug 17, 2020 · 2 comments

Comments

@pkly
Copy link

pkly commented Aug 17, 2020

As far as I can see there's no easy way to modify the payloads for AuthCode and AccessToken/RefreshToken.

It'd be nice if there would be an event about the user being used in the request along with the entities free to modify, the custom data could just be stored as json in the entity itself.

As of now I'm simply creating an additonal entity, linking it to the AccessToken entity (or AuthCode entity), and making my own AccessTokenRepository or AuthCodeRepository where I modify some functions. (btw shame those classes are final)

@froozeify
Copy link

Hey, I've looked for a way to implement that with an event since my current PR is about that.

Unfortunately, when adding custom value those didn't appear in the JWT payload.

By doing further investigation I find out that it was not supported in thephpleague/oauth2-server and apparently they didn't want to support it, to avoid having heavy payload and other ...

I just did a quick search over it, maybe they now allow it, in that case tell me and i'll try to add to my PR or in a future one ;-)

@DevNiko
Copy link

DevNiko commented Jan 29, 2021

@pkly You could extend the "BearerTokenResponse" of the League Bundle and override the "getExtraParams()" Method. See the Comment of the Method.

This Bundle here (Thanks to Steve Rhoades) uses this Method to inject an open ID Token to the Response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants