fix(keyring): clear stale access-token chunks instead of deleting the client secret#1527
Merged
Merged
Conversation
ramya18101
approved these changes
May 20, 2026
Contributor
|
Hi @sparkling 👋, This is a great catch! Thanks for finding this and putting together. Also please sign your commit! |
… client secret StoreAccessToken's "clear existing chunks" loop deleted the secretClientSecret key on every iteration instead of the indexed secretAccessToken chunks. Two consequences: 1. Stale access-token chunks were never cleared, so re-storing a shorter token left trailing chunks that concatenated into a malformed JWT, surfacing as "authentication token is corrupted". 2. The client secret was deleted immediately after a machine login stored it, so RegenerateAccessToken could no longer refresh the token and client-credentials sessions broke at the first expiry. Delete the indexed access-token chunks (matching DeleteSecretsForTenant and the store/get loops) and leave the client secret untouched. Adds regression tests covering both failure modes. Introduced in auth0#1358.
d075c00 to
bb4e919
Compare
ramya18101
approved these changes
May 21, 2026
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.
Description
StoreAccessToken's "clear existing chunks" loop deleted thesecretClientSecretkey on every iteration instead of the indexedsecretAccessTokenchunks (introduced in #1358). This caused two failures:authentication token is corrupted.RegenerateAccessToken → GetClientSecretfailed and client-credentials sessions broke at the first token expiry (and never auto-renewed).The loop now deletes the indexed access-token chunks (matching
DeleteSecretsForTenantand the store/get loops) and leaves the client secret untouched.Fixes #1526
Testing
Added two regression tests in
internal/keyring/keyring_test.go:StoreAccessTokendoes not delete the client secretBoth fail on
mainand pass with this change. Also verified end-to-end against a live tenant: a machine login followed by a forced token expiry now auto-renews silently instead of erroring withplease re-authenticate.Checklist
go test ./internal/keyring/...passes