-
-
Notifications
You must be signed in to change notification settings - Fork 614
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
Potential SF6 Compat Issue - JWTManager::addUserIdentityToPayload()
by default requires a username property or getUsername method
#881
Comments
Thanks for the issue. You're right here. |
@chalasr Exactly as you write. It is a simple and very important thing. When can we count on a correction? |
Thanks for the ping @malkavi6, I totally forgot about this. I'm going to look at it in the coming days |
Bump. I need to be able to replace the username with another user property. |
same issue here, is there a way to configure what field is used? |
maybe there should just be check like;
and not rely on hard coded |
This is what I'm using right now, we haven't moved up to Symfony 6 yet but from what I remember this shouldn't cause any issues: lexik_jwt_authentication:
user_identity_field: 'email' # Any of the properties/getters in the user object
user_id_claim: 'username' # The fieldname used in the JWT payload for the user identity |
I will look into this asap, hopefully next week. |
I agree that config option is not needed. |
Perfect, that's what I meant. |
Hello. |
See #1037 |
Should the docs be updated to reflect this change? I was looking at setting up the bundle, realized it assumed a I'd be willing to pr removing Thanks for adding this change though 👌 |
@Aweptimum I think a small comment around the |
With the default bundle configuration,
JWTManager::addUserIdentityToPayload()
adds the user identity to the JWT payload by using a property accessor to fetch the configureduserIdentityField
from the User object, which defaults to "username". WithUserInterface::getUsername()
going away in Symfony 6, this default configuration looks like it could start to cause problems in one of two ways:UserInterface
implementation to have either a$username
property or agetUsername()
method with the out-of-the-box configuration$userIdentityField
property to "userIdentifier" to match the updatedUserInterface
(since the implementation details of the property accessor say it will try to use a getter for that field name) by default also changes the name of the user ID claim in the JWT payload, unless you also configure theuser_id_claim
config node which cascades down to the$userIdClaim
property; IMO these types of changes to the defaults in the bundle would be a B/C break so couldn't really be considered before a 3.0 release (but, bundle users can make updates through the bundle config)Personally, I'd say to deprecate the
user_identity_field
bundle config and theuserIdentityField
property in the manager and just use theUserInterface
by default, and if someone needs to use something that isn't the result ofgetUsername()
orgetUserIdentifier()
, they can subclass the manager and override theaddUserIdentityToPayload()
method, but I also realize #40 added this for a specific reason so maybe that isn't the greatest of solutions.The text was updated successfully, but these errors were encountered: