Enforce OAuth read-only for cloud commands#99
Merged
Conversation
…date docs OAuth device flow tokens are now treated as read-only. Write commands (create, update, delete, start, stop, scale, etc.) are blocked early in the CLI when using Bearer auth, with a clear error guiding users to API key authentication. - Add is_bearer_auth() to CloudClient to expose auth mode - Add is_write_command() to CloudCommands with exhaustive matching (no wildcards) so new commands must be classified at compile time - Pre-check gate in run_cloud() blocks writes before API calls - 403 responses with OAuth include a hint about API key auth - auth status now shows [read-only] / [read/write] labels - Updated help text, CONTEXT FOR AGENTS, and README Closes #98 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The command `cloud auth keys` doesn't exist. Replace with the actual `cloud auth login --api-key KEY --api-secret SECRET` syntax, and note the read-only vs read/write distinction. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace sample-based tests with exhaustive coverage of all 44 cloud command variants. Tests parse real CLI args through clap, validating both parsing and read/write classification. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add https://clickhouse.com/docs/cloud/manage/openapi?referrer=clickhousectl to the pre-check gate error, 403 OAuth hint, no-credentials error, and README. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previously only hidden in release builds. This is an internal flag for testing against staging/dev environments and should never be visible to users or agents. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…learing `cloud auth logout` still clears everything by default. New flags: --oauth clear only OAuth tokens, keep API keys --api-keys clear only API keys, keep OAuth tokens The flags are mutually exclusive. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The OAuth read-only note already covers this. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New order: CLI flags > file credentials > env vars > OAuth tokens. API keys are project-scoped (read/write) and should take precedence. OAuth is user-scoped (read-only) and serves as a fallback when no API keys are configured. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
add signup command
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Restore cfg_attr(debug_assertions) so --url is visible in debug builds but hidden in release builds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
iskakaushik
approved these changes
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
match(no wildcards), so new commands must be classified at compile time.cloud auth statusnow shows[read-only]/[read/write]labels.Closes #98
Changes
src/cloud/client.rsis_bearer_auth()method + OAuth hint on 403 errorssrc/cloud/cli.rsis_write_command()with exhaustive matching + updated help textsrc/main.rsrun_cloud()+[read-only]/[read/write]in auth statussrc/cli.rsREADME.mdTest plan
cargo build— compilescargo test— all 251 tests passcargo clippy— cleancargo run -- cloud auth status— verify[read-only]/[read/write]labelscargo run -- cloud --help— verify updated agent contextcargo run -- cloud auth login --help— verify read-only noteservice create→ clear error messageservice create→ works normallyFollow-ups
🤖 Generated with Claude Code