Skip to content
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

Introduce a factory service for generating RefreshTokenInterface objects #251

Merged
merged 1 commit into from
Jul 12, 2021

Conversation

mbabker
Copy link
Contributor

@mbabker mbabker commented Jul 1, 2021

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:

  • Changes the generator logic to use random_bytes() instead of openssl_random_pseudo_bytes()
  • Deprecates calling RefreshTokenInterface::setRefreshToken() with an empty value and having the model automatically generate a new token value, callers should handle generating the values
  • Deprecates the Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface::create() method in favor of the generator interface
  • Deprecates the Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManager class, it only provides the deprecated create() method so it's better for managers to just implement the interface directly going forward
  • Removes the dependency on symfony/validator since the generator should be doing all validation itself now
  • Misc. test updates

B/C concerns now that a 1.0 beta is tagged:

  • The constructor arguments of Gesdinet\JWTRefreshTokenBundle\EventListener\AttachRefreshTokenOnSuccessListener are adjusted to use the new generator and remove the validator
  • Adds the Gesdinet\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

@markitosgv markitosgv merged commit a30e372 into markitosgv:master Jul 12, 2021
@mbabker mbabker deleted the token-generator branch July 12, 2021 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants