Repository navigation
Description
Describe the bug
When deleting a context with microcks context <name> --delete, the CLI removes the context and server entries but does not remove the associated user credentials when the context was created with a custom name via login --name.
login stores users under the server URL (users[].name), while contexts use the context name (contexts[].name) and reference the user through contexts[].user.
However, deleteContext calls RemoveUser(context) using the context name. For a named context like dev, the actual user entry is keyed by http://localhost:8080, so cleanup silently fails.
This can leave OAuth tokens and related auth records in ~/.config/microcks/config even after the user is told Context 'dev' deleted.
Expected behavior
After microcks context dev --delete:
- The
devcontext entry is removed fromcontexts - The related
servers,usersauth-token / refresh-token, andauthsentries for that Microcks instance are removed - No OAuth tokens or Keycloak client credentials remain on disk for that deleted context
Actual behavior
After deleting a named context:
- The
contextsentry is removed - The related
serversentry is removed - The related
usersentry remains, includingauth-tokenandrefresh-token - The CLI prints
Context 'dev' deletedwith no warning that credentials were left behind
How to Reproduce?
Reproducer:
- Create a temporary config:
mkdir -p /tmp/microcks-cli-verify
cat > /tmp/microcks-cli-verify/config <<'EOF'
current-context: staging
contexts:
- name: dev
server: http://localhost:8080
user: http://localhost:8080
instance: ""
- name: staging
server: http://localhost:8083
user: http://localhost:8083
instance: ""
servers:
- server: http://localhost:8080
insecureTLS: true
keycloakEnable: true
- server: http://localhost:8083
insecureTLS: true
keycloakEnable: true
users:
- name: http://localhost:8080
auth-token: LEAKED-TOKEN
refresh-token: LEAKED-REFRESH
- name: http://localhost:8083
auth-token: ""
refresh-token: ""
auths:
- server: http://localhost:8080
clientId: my-client
clientSecret: my-secret
EOF
chmod 600 /tmp/microcks-cli-verify/config- Delete the named context:
./build/dist/microcks context dev --delete --config /tmp/microcks-cli-verify/config- Inspect the config:
cat /tmp/microcks-cli-verify/config
Microcks version or git rev
Microcks-CLI 1.0.2
Install method (docker-compose, helm chart, operator, docker-desktop extension,...)
No response
Additional information
No response
Activity
cotishq commentedon May 24, 2026
@Harsh4902 , would love your opinion on this, if this looks relevant to you, i can open a pr against it
Caesarsage commentedon Aug 16, 2026
Thanks @cotishq
This has been fixed on master , deleteContext now resolves the context first and removes the referenced user (and its tokens) via the context's own user reference, not the context name, and only when no other context still references it.
I believe this can be closed.
cotishq commentedon Aug 18, 2026
@Caesarsage ok, i will close this issue