Skip to content

bug: logout cannot handle named contexts despite documented usage #419

@gyanranjanpanda

Description

@gyanranjanpanda

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

  1. Log in with a named context:
microcks login https://microcks.example --name staging
  1. Try to log out using the documented named context form:
microcks logout staging

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions