Skip to content

fix: persist refreshed tokens against the context user - #627

Open
dipak0000812 wants to merge 1 commit into
microcks:masterfrom
dipak0000812:fix/536-token-refresh-user-reference
Open

dipak0000812 wants to merge 1 commit into
microcks:masterfrom
dipak0000812:fix/536-token-refresh-user-reference

Conversation

@dipak0000812

Copy link
Copy Markdown
Contributor

Fixes #536

Description

When automatic token refresh runs, refreshAuthToken uses the context name (ctxName) instead of the referenced user's name (configCtx.User.Name) when persisting refreshed credentials.

For contexts created with a custom name, this creates an orphaned user entry while leaving the actual referenced user with expired tokens.

This change updates the existing user entry using configCtx.User.Name.

Tests

  • Added TestRefreshAuthToken_PersistsTokensAgainstContextUser.
  • Verified the test reproduces the issue before the fix.
  • Verified refreshed tokens update the referenced user without creating an orphaned entry.
  • Connector tests and go vet ./pkg/connectors/... pass.
  • git diff --check passes.

AI Disclosure

AI assistance was used during investigation and test development. I reviewed and validated the changes and take full responsibility for the implementation.

When automatic token refresh executes, refreshAuthToken resolved the
context but called localCfg.UpsertUser using ctxName instead of the
referenced user's name (configCtx.User.Name).

For contexts created with a custom name (e.g. via microcks login <server> --name <ctx>),
the referenced user is keyed by server URL while the context name differs.
Using ctxName caused an orphaned user entry to be created with the new
tokens while leaving the referenced user with the expired tokens.

Fix this by upserting refreshed tokens against configCtx.User.Name and
add regression test coverage.

Closes microcks#536

Signed-off-by: Dipak Dhangar <[email protected]>

This branch had an error being deployed

1 failed deployment
Build — 9f916168 Deployed Nov 12, 2026 by dipak0000812 via build-verify-package #884
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.

token refresh saves tokens under the context name instead of the user name

1 participant