Repository navigation
Conversation
GET /v1/organizations/{organizationId}/roles answers differently by auth:
an API key gets the administrative catalog (RBACRole), a CLI user Bearer
token gets the roles that user may assign. Model the second as its own
method, organization_assignable_roles_get_list, with AssignableRole,
AssignableRolePolicy and AssignableRolePolicyTags.
The method refuses Basic clients locally with AuthMismatch instead of
falling back to the catalog. Fields stay Option, per the library's
compatibility policy, so callers can tell a missing policy list from an
empty one. The analyzer allowlists the extra typed helper for the
existing route.
…lane Rename from_resolved to from_resolved_auth and pass the resolved auth straight through. Normalize the saved OAuth API URL in for_oauth_tokens, as every other construction path already does, so a record saved without the /v1 suffix resolves the same base URL. Extract print_client_diagnostics from the --debug block so a command that builds its own client can report the same credential source and API URL.
`cloud access` lets an agent get a short-lived, narrowly scoped API key that a human approves in the browser, instead of reusing a long-lived key. It is compiled only with the new `experimental-access-negotiation` feature, so published binaries carry none of it; CI runs clippy and tests with it on. Identity: both subcommands refresh and use the OAuth user login (`CloudClient::for_access`), never an API key, even when one outranks it. The API URL is `--url`, else the one saved with the login. The organization comes from the user's complete membership list: one is picked automatically, otherwise `--org`/`--org-id` or `--org-name`. Selectors are reparsed without clap's global propagation, which would otherwise hide a conflict between values given at different command depths. `cloud access roles` prints the assignable-role menu. Incomplete roles or policies fail before any output instead of implying an empty permission set. `cloud access request` runs the authorization code flow with PKCE (RFC 7636) over a loopback redirect (RFC 8252): 1. bind 127.0.0.1 (or [::1]) and file the request with the redirect URI, S256 challenge, CSRF state and an optional `--perms role:<UUID>` proposal; 2. print the approval URL to stderr and open the browser; 3. wait for the redirect, which carries the code or `error=access_denied`; the wait is bounded by the server's pending deadline and `--timeout-seconds` (default two minutes), and the request status is never read; 4. exchange code, verifier and redirect URI for the key, and save it to `.clickhouse/credentials.json`. The handshake client never follows redirects, so the code and verifier cannot be replayed to another origin. Server messages are bounded and scrubbed of the code and verifier. Each HTTP operation is capped at 30 seconds. Filing and the exchange are not retried. JSON stdout contains only the final result. Docs live in the authentication reference, under an experimental heading, rather than the README.
Serve dedicated approved and denied loopback pages styled like the console's access-request confirmation view, with a 5-second countdown that tries to close the tab.
Root, cloud, cloud service, access request, auth login/signup help and the auth status write_access field. API-key login is no longer named in agent context. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
|
This branch has not been deployed
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.
What
With
experimental-access-negotiationcompiled in, theCONTEXT FOR AGENTShelp now sends an agent on a read-only OAuth login tocloud access requestwhen it needs a write, and no longer tells it to log in with an API key.#1495 added this pointer to the write-gate error. In practice agents rarely reach that error: root help,
cloud --helpandcloud auth statusalready tell them OAuth is read-only and that writes need an API key, so they stop and ask the user for one before trying a write. This PR changes what those screens say.Why on top of
feature-access-requestSame reason as #1495:
cloud accessexists only under#[cfg(feature = "experimental-access-negotiation")], so help that names it has to sit behind the same gate. Every string changed here is cfg-selected. A default build is unchanged: all 300--helpscreens are byte-identical to the base commit.Change (feature on only)
OAuth is read-only. For writes, run cloud access request (the user approves it, requires OAuth)), and the typical flow now goescloud auth signup->cloud auth login->cloud access request->cloud service create. The "Check state first" line is replaced byCheck auth status: cloud auth status.cloudOAuth is read-only: for writes, run `cloud access request` (the user approves it).The typical flow drops the API-key login. Thecloud auth whoamiline and thecloud auth status/--org-idline are removed; the second repeated the subcommand's description and the--org-idoption text.cloud serviceOther commands are writes: on OAuth, run `cloud access request` first.cloud access requestcloud access(description)cloud auth logincloud access requestadded. The--api-key/--api-secretflags and their option help are untouched.cloud auth signupNext:is nowcloud auth login.cloud auth statusoutputwrite_accessfield in JSON, and aWrite access:line in the table output, shown only while OAuth is the active source. It namescloud access rolesandcloud access request --perms role:<UUID>.Error messages are not changed.
Evidence
Agent runs on one task that needs a control-plane write and SQL writes, starting from a read-only OAuth login, with access requests approved automatically. 20 runs per row.
The four unfinished runs all failed after approval, for reasons this PR does not address: three ran the CLI from another directory, where the saved key is not found and the CLI falls back to the OAuth login without saying so, and one requested a role without SQL access.
Not yet run against real Cloud with a person approving or declining.
Open points for review
cloud access requestblock is now 9 content lines against the standard's 8. This PR raises the cap to 9 for that one path inwhole_command_tree_follows_help_structure. Folding one line of that block would be the cleaner fix; it is left as evaluated so the wording matches the runs above.root_agent_context_status_commands_parseis compiled out when the feature is on, because the new root context no longer lists--jsonstatus commands.main. feat(cli): name Postgres in root help, typical flows and search (#1493) #1494 changed the root agent context onmain(it added a Postgres line). The feature-on root here has its own Postgres and ClickHouse lines, so mergingmainintofeature-access-requestwill need the two reconciled.cloud servicein root. The ClickHouse line namescloud service; it should follow the rename if Rename cloud service to cloud clickhouse (ch), keep service as a hidden alias #1499 lands.postgres,query-api-endpoint,saved-query,backup,clickpipe,clickstack,udf) still say writes need API key auth. They should get the same one-line change ascloud service.Checks
cargo fmt --all --check,cargo clippy -p clickhousectl --all-targetsandcargo test -p clickhousectlpass with and without--features experimental-access-negotiation.🤖 Generated with Claude Code
Note
Low Risk
Changes are cfg-gated help text and optional status output fields only; no change to default binaries or write-gate behavior.
Overview
When
experimental-access-negotiationis enabled, CONTEXT FOR AGENTS help is rewritten so coding agents route write operations throughcloud access requestafter a read-only OAuth login, instead of instructing them to log in with API keys. Root,cloud,cloud auth login/signup,cloud service, andcloud access requesthelp are feature-gated; builds without the flag stay byte-identical.cloud auth statusnow surfaceswrite_access(JSON and human output) when OAuth is the active credential, pointing agents atcloud access rolesandcloud access request --perms role:<UUID>.Help-structure tests allow 9 context lines for
cloud access requestonly, and skip the root--jsonstatus-command parse test when the new root context no longer names those commands.Reviewed by Cursor Bugbot for commit 970df53. Bugbot is set up for automated code reviews on this repo. Configure here.