thephpleague / oauth2-server

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

Make UserEntityInterface Api more compatible with AccessTokenEntityInterface #998

Closed vidalvasconcelos closed 5 years ago

vidalvasconcelos commented 5 years ago

I implementing an package for Zend Expressive and noticed a possible improvement in UserEntityInterface API.

The AccessTokenEntityInterface extends TokenInterface, this interface require a setUserIdentifier method but UserEntityInterface not have a setIdentifier, for simple use, this does not cause any problem. but will have great value to improve the isolation these entities.

screenshot 2019-02-20 16 36 24 screenshot 2019-02-20 16 37 44
Sephster commented 5 years ago

At the moment, I can't see a use case for this change. The UserEntityInterface is a representation for a user entity which is stored in the DB. Typically the ID of the user would be set when the record is retrieved from the DB and the implementing object is created.

I can't think of a scenario where we would subsequently update the ID or create the entity without knowing the ID in advance and setting it later.

I'm sure there will be some use cases but I don't think they're that common and I'm struggling to think of one I've come across of late.

I appreciate why it appears odd having a getter without a setter, and that this doesn't match other interfaces. Happy to review this if any users state a clear use case where they need a setter to modify the ID but at the moment I think we will leave this as is.

Thank you very much for getting in touch regarding this. Hope you have a great weekend.