Skip to content

fix: clean up auth when deleting named contexts#436

Open
cotishq wants to merge 1 commit into
microcks:masterfrom
cotishq:fix/context-delete-named-context-auth-cleanup
Open

fix: clean up auth when deleting named contexts#436
cotishq wants to merge 1 commit into
microcks:masterfrom
cotishq:fix/context-delete-named-context-auth-cleanup

Conversation

@cotishq

@cotishq cotishq commented May 25, 2026

Copy link
Copy Markdown
Contributor

Description

  • Fixes named context deletion so cleanup uses the removed context's referenced user and server values instead of the context name.
  • Removes the associated auth entry when deleting a context, matching the expected cleanup behavior for credentials tied to that server.
  • Adds a regression test covering context --delete for a named context where contexts[].name differs from contexts[].user.

Screenshot

Screenshot From 2026-05-25 12-04-04

Related issue(s)

Fixes #427

@cotishq
cotishq force-pushed the fix/context-delete-named-context-auth-cleanup branch from bcbd734 to 46a68ba Compare May 25, 2026 06:37
@cotishq

cotishq commented May 29, 2026

Copy link
Copy Markdown
Contributor Author

hey @Harsh4902 , would love your feedback here

@Vaishnav88sk

Copy link
Copy Markdown

@cotishq Please resolve the conflicts.

@Vaishnav88sk

Copy link
Copy Markdown

The current delete path uses the context name for user cleanup, which is wrong for named contexts where contexts[].name != contexts[].user. Cleaning up by the removed ContextRef is the right direction, and adding auth cleanup for the associated server also makes sense.

One thing to double-check before merge: are server, user, or auth entries ever intentionally shared by multiple contexts? If yes, deleting them unconditionally here could remove credentials/config still referenced by another context. If they are always 1:1 with a context, then this is fine.

If shared references are not a supported case, LGTM. @Harsh4902

Signed-off-by: cotishq <tanishqp101204@gmail.com>
@cotishq
cotishq force-pushed the fix/context-delete-named-context-auth-cleanup branch from 46a68ba to 252197d Compare July 16, 2026 18:37
@cotishq

cotishq commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

yeah you are right, since microcks login supports the --name flag, users can define multiple named contexts pointing to the same server or user. so if one is deleted, deleting the server, user or auth config unconditionally would indeed break the remaining contexts that reference them.

i think we should check if any other contexts still reference the removed contexts user or server before deleting them.

what's your opinion should i update the PR to add references checking ?

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.

bug: context --delete leaves stale auth tokens for named contexts

2 participants