Skip to content

feat(cli): add optional server-side revocation to auth logout#371

Merged
peteski22 merged 2 commits into
mainfrom
cli/logout-revoke
May 14, 2026
Merged

feat(cli): add optional server-side revocation to auth logout#371
peteski22 merged 2 commits into
mainfrom
cli/logout-revoke

Conversation

@peteski22
Copy link
Copy Markdown
Collaborator

Summary

  • Add cq auth logout --revoke and cq auth logout --revoke --all-devices while preserving default local-only logout behavior.
  • Extend the auth HTTP client with a logout call to /api/v1/auth/logout (including all_devices=true) and map unsupported endpoint statuses to a typed ErrLogoutUnsupported.
  • Implement revoke-aware logout flow semantics: keep local credentials on non-401 revoke failures, clear locally on expired-session revoke responses, and keep no-credential logout idempotent.

Testing

  • Add command-level tests for --all-devices dependency on --revoke, revoke requiring configured address, and successful revoke+clear flow.
  • Add auth-layer tests for revoke success, revoke failure preserving creds, expired-session revoke behavior, and HTTP client logout path/query/status handling.
  • Run make lint-cli and make test-cli from repo root.

Introduce cq auth logout --revoke and --all-devices so users can request backend session invalidation while preserving local credentials on non-recoverable revoke failures.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional server-side session revocation flow to cq auth logout, while keeping the default behavior as local-only credential cleanup. This extends the CLI auth client with a /api/v1/auth/logout call and introduces revoke-aware logout semantics and tests across the auth and cobra layers.

Changes:

  • Add cq auth logout --revoke and --all-devices flags (with validation that --all-devices requires --revoke).
  • Implement auth-layer Client.Logout and wire revoke-first logout behavior (including “expired session” handling).
  • Add tests covering command flag behavior and auth/http client status handling.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cli/README.md Documents new logout --revoke / --all-devices usage and semantics.
cli/internal/auth/platform_client.go Extends the auth Client interface with Logout.
cli/internal/auth/onboarding_test.go Updates test stub client to satisfy the extended interface.
cli/internal/auth/logout.go Implements revoke-aware logout flow and local credential clearing semantics.
cli/internal/auth/logout_test.go Adds unit tests for revoke success/failure/expired-session behavior.
cli/internal/auth/http_client.go Adds HTTP implementation of Logout and status-to-error mapping.
cli/internal/auth/http_client_test.go Adds request/response tests for the new logout endpoint behavior.
cli/internal/auth/errors.go Introduces typed ErrLogoutUnsupported.
cli/internal/auth/doc.go Updates package doc to reflect server-side revocation capability.
cli/cmd/auth.go Adds cobra flags and wiring for revoke/all-devices logout.
cli/cmd/auth_test.go Adds command-level tests for new flag semantics and revoke flow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cli/internal/auth/http_client.go
Comment thread cli/internal/auth/http_client.go
Comment thread cli/internal/auth/logout.go Outdated
Comment thread cli/README.md Outdated
@peteski22 peteski22 merged commit d2a255b into main May 14, 2026
2 checks passed
@peteski22 peteski22 deleted the cli/logout-revoke branch May 14, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants