thephpleague / oauth2-server

A spec compliant, secure by default PHP OAuth 2.0 Server
https://oauth2.thephpleague.com
MIT License
6.52k stars 1.12k forks source link

[Feature request] Custom JWT claim #1327

Closed sylfabre closed 1 year ago

sylfabre commented 1 year ago

My use-case is to add basic information about the user currently logged in like first name, last name, or email. I'm using several types of authentification with several sources of users and different JWT token => I'd like to have a custom "source" claim in the JWT so Symfony authentification could pick the right service to handle the token based on this "source" claim value.

Also, I'm using this lib as an SSO: as-is, the Service Provider needs to make an API call to get information about the user related to the token. I'm thinking of adding claims like "first name", "last name", or "email".

Right now, the only way is to override the convertToJWT() method from https://github.com/thephpleague/oauth2-server/blob/master/src/Entities/Traits/AccessTokenTrait.php

I guess that https://github.com/thephpleague/oauth2-server/issues/1154 could be leverage to let users "hook" in the JWT generation too :)

parallels999 commented 1 year ago

Is #1122 what you are looking for? Also https://github.com/thephpleague/oauth2-server/pull/1328 could help

sylfabre commented 1 year ago

@parallels999 good call, https://github.com/thephpleague/oauth2-server/pull/1328 is what I'm looking for!

Sephster commented 1 year ago

Marking this as closed as we have PRs/Issues already noting this request. Thanks