decouple unique identifier generation #987
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I am working on an implementation using level 4 Uuids as unique identifiers for the tokens and auth code. My first approach was to create a custom Grant overriding the
generateUniqueIdentifier
function fromAbstractGrant
, but implementing the second grant I felt the urge to decouple the identifier generation.This PR:
AbstractGrant::generateUniqueIdentifier
toIdentifierGeneratorInterface::generateUniqueIdentifier
IdentifierGenerator
containing the moved method from theAbstractGrant
AuthorizationServer
s constructor (optional). If it is not set the default generator is used instead and set on the Grant inside theAbstractGrant::enableGrantType
functionDiscussion
My first idea was to inject the
IdentifierGeneratorInterface
into theAbstractGrant
constructor, to be sure it would alwas be set when calling$this->identifierGenerator->generateUniqueIdentifier()
, but after looking closer at the existing code I realized that common dependencies used by the different grant types where set in theAbstractGrant::enableGrantType
function, so I followed that pattern. I am not sure this is the preferred way, so may need some feedback on this.