Skip to content

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

Merged
Harsh4902 merged 1 commit into
microcks:masterfrom
dipak0000812:fix/536-token-refresh-user-reference
Nov 25, 2026
Merged

Harsh4902 merged 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]>
@dipak0000812
dipak0000812 force-pushed the fix/536-token-refresh-user-reference branch from 9f91616 to ff80dd3 Compare November 14, 2026 08:37

@Harsh4902 Harsh4902 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @dipak0000812 for the PR :)

@Harsh4902 Harsh4902 added component/cli go Pull requests that update go code labels Nov 25, 2026
@Harsh4902 Harsh4902 added this to the Next milestone Nov 25, 2026
@Harsh4902
Harsh4902 merged commit 830fc9b into microcks:master Nov 25, 2026
4 checks passed
@dipak0000812
dipak0000812 deleted the fix/536-token-refresh-user-reference branch November 25, 2026 17:23

This branch was successfully deployed

1 active deployment
Build — ff80dd35 Deployed Nov 14, 2026 by dipak0000812 via build-verify-package #890
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/cli go Pull requests that update go code

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

2 participants