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

Add regenerateToken method to HasApiTokens #509

Closed
wants to merge 2 commits into from

Conversation

FatefulNur
Copy link

@FatefulNur FatefulNur commented Apr 6, 2024

This PR introduces new regenerateToken method to the HasApiTokens traits in Laravel Sanctum. This method allows users to regenerate a new personal access token while revoking the existing one.

Changes:

  • Added regenerateToken method to the HasApiTokens traits and contract.
  • Implemented functionality to delete existing tokens and generate a new one with specified attributes.

Use-Case

For scenarios requiring frequent rotation of access tokens to mitigate security risks, the addition of a regenerateToken method to Laravel Sanctum can greatly simplify token management without manually creating it into our own model.

Testing:

A unit test have been added to ensure the proper functionality of the regenerateToken method.

@RahulDey12
Copy link
Contributor

why it's deleting all the token it should delete the transit token instead of all.

@FatefulNur
Copy link
Author

FatefulNur commented Apr 6, 2024

@RahulDey12 thanks for your advice. Could you tell what's the regard to delete only the transient token?

@RahulDey12
Copy link
Contributor

It mean that we are logging out.

@FatefulNur FatefulNur closed this Apr 7, 2024
@FatefulNur
Copy link
Author

May be the idea wasn't relevant with api tokens.

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.

None yet

2 participants