Introduce a factory service for generating RefreshTokenInterface objects #251
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.
Indirectly, this helps out with #191
This extracts out the main logic for creating
RefreshTokenInterface
instances into a generator interface which should simplify the workflow for creating them if you're not using the event listener. Instead of having to manually find and configure all of the model's values (which may include wiring up services to use the container parameters from this bundle) and manually handle validation, the generator interface will compute the values from the provided arguments and handle ensuring that we have a unique token on its own.Notable changes:
random_bytes()
instead ofopenssl_random_pseudo_bytes()
RefreshTokenInterface::setRefreshToken()
with an empty value and having the model automatically generate a new token value, callers should handle generating the valuesGesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface::create()
method in favor of the generator interfaceGesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManager
class, it only provides the deprecatedcreate()
method so it's better for managers to just implement the interface directly going forwardsymfony/validator
since the generator should be doing all validation itself nowB/C concerns now that a 1.0 beta is tagged:
Gesdinet\JWTRefreshTokenBundle\EventListener\AttachRefreshTokenOnSuccessListener
are adjusted to use the new generator and remove the validatorGesdinet\JWTRefreshTokenBundle\Model\RefreshTokenInterface::createForUserWithTtl()
method, the intent is to have the static factory that ensures the model is created with all properties in a valid state