Summary
microcks logout CONTEXT is documented as supporting a named context, but the implementation passes the provided argument directly to LocalConfig.RemoveToken. That function searches LocalConfig.Users by user name, while login --name <name> stores the user under the server URL and stores the friendly name only in ContextRef.Name.
As a result, logging in with a named context works, but logging out by that same context name fails and leaves the auth and refresh tokens in the local config.
Evidence from the code
cmd/login.go stores the user with Name: server, then stores the named context with Name: ctxName and User: server.
cmd/logout.go reads context := args[0] and calls localCfg.RemoveToken(context) directly.
pkg/config/localconfig.go implements RemoveToken by comparing u.Name == serverName, so a context alias such as staging will not match the stored user name such as https://microcks.example.
Reproduction
- Log in with a named context:
microcks login https://microcks.example --name staging
- Try to log out using the documented named context form:
Actual behavior
The command fails with a message like:
Context staging does not exist
The token entry stored under the server URL remains in the config file.
Expected behavior
microcks logout staging should resolve the context name first, find the referenced user/server entry, and clear the associated auth and refresh tokens. If the CLI also wants to keep accepting raw server URLs, it can support both forms, but the documented named-context form should work.
Impact
This affects a core authentication workflow. Users who use named contexts can believe they are logging out, but the CLI cannot clear their tokens unless they know to pass the underlying server URL instead of the context name.
Summary
microcks logout CONTEXTis documented as supporting a named context, but the implementation passes the provided argument directly toLocalConfig.RemoveToken. That function searchesLocalConfig.Usersby user name, whilelogin --name <name>stores the user under the server URL and stores the friendly name only inContextRef.Name.As a result, logging in with a named context works, but logging out by that same context name fails and leaves the auth and refresh tokens in the local config.
Evidence from the code
cmd/login.gostores the user withName: server, then stores the named context withName: ctxNameandUser: server.cmd/logout.goreadscontext := args[0]and callslocalCfg.RemoveToken(context)directly.pkg/config/localconfig.goimplementsRemoveTokenby comparingu.Name == serverName, so a context alias such asstagingwill not match the stored user name such ashttps://microcks.example.Reproduction
microcks logout stagingActual behavior
The command fails with a message like:
The token entry stored under the server URL remains in the config file.
Expected behavior
microcks logout stagingshould resolve the context name first, find the referenced user/server entry, and clear the associated auth and refresh tokens. If the CLI also wants to keep accepting raw server URLs, it can support both forms, but the documented named-context form should work.Impact
This affects a core authentication workflow. Users who use named contexts can believe they are logging out, but the CLI cannot clear their tokens unless they know to pass the underlying server URL instead of the context name.