Repository navigation
Revoke a user's own Sanctum tokens, never another model's - #72
Merged
Merged
Conversation
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
SanctumTokenIssuer::revokeAll(), called on every password reset and update, queried the token table by a morph type taken from configuration instead of the user's own. A second token-bearing model with a colliding id (an Admin with id 5) therefore revoked User 5's tokens and kept its own. It also queried that table for user models that hold no Sanctum tokens, so a reset failed where the table does not exist. Revoke through the user's own tokens() relation, and only for models that use Sanctum's HasApiTokens: the behaviour before the registry, now scoped to the Sanctum issuer so Passport's tokens stay with its own. Restores the rationale for the ability and expiry defaults that the move into SanctumTokenIssuer dropped. Three tests, two failing before.
imanimanyara
force-pushed
the
fix/sanctum-revoke-all
branch
from
October 8, 2026 20:10
c639ac9 to
cb237c6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
SanctumTokenIssuer::revokeAll(), called on every password reset and
update, queried the token table by a morph type taken from configuration
instead of the user's own. A second token-bearing model with a colliding
id (an Admin with id 5) therefore revoked User 5's tokens and kept its
own. It also queried that table for user models that hold no Sanctum
tokens, so a reset failed where the table does not exist.
Revoke through the user's own tokens() relation, and only for models
that use Sanctum's HasApiTokens: the behaviour before the registry, now
scoped to the Sanctum issuer so Passport's tokens stay with its own.
Restores the rationale for the ability and expiry defaults that the move
into SanctumTokenIssuer dropped. Three tests, two failing before.