Repository navigation
Conversation
balanza
temporarily deployed
to
cloud-integration
November 13, 2026 06:17 — with
GitHub Actions
Inactive
Collaborator
Author
|
|
balanza
marked this pull request as ready for review
November 13, 2026 07:02
balanza
force-pushed
the
feature-access-request
branch
2 times, most recently
from
November 17, 2026 12:31
2fd91f2 to
1b0fe5a
Compare
balanza
force-pushed
the
feature-access-request
branch
from
November 17, 2026 14:47
336fb52 to
110b8a0
Compare
Collaborator
Author
|
|
|
|
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.
balanza
force-pushed
the
feature-access-request
branch
from
November 19, 2026 16:39
fa0a2ca to
d71f375
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d71f375. Configure here.
sdairs
approved these changes
Nov 24, 2026
This branch was previously 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.

Fixes #1131
Supersedes #1132
What
cloud accesslets an agent get a short-lived, narrowly scoped API key that a person approves in the browser, so it doesn't have to reuse a long-lived key with broad permissions.cloud access roleslists the roles the OAuth user can assign in the selected organization.cloud access request [--perms role:<UUID>,…]files a request, waits for approval in the browser, and saves the issued key to.clickhouse/credentials.json.Both commands are compiled only with the
experimental-access-negotiationcargo feature. Published binaries don't include them; CI runs clippy and tests with the feature enabled.How the request works
Authorization code flow with PKCE (RFC 7636) and a loopback redirect (RFC 8252):
127.0.0.1(or[::1]). File the request with the redirect URI, the S256 challenge, a CSRFstateand an optional role proposal.codeorerror=access_denied. The wait ends at the server's pending deadline or after--timeout-seconds, whichever comes first (default two minutes). The request status is never polled.Identity is always the refreshed OAuth user login, never an API key, even when one would win normal precedence. The organization comes from the user's membership list: a single membership is selected automatically; otherwise use
--org/--org-idor--org-name.Reviewing
Each commit builds and passes tests on its own:
test(cli): an unrelated test isolation fix.feat(api): library-onlyorganization_assignable_roles_get_listand theAssignableRole*models. Bearer only; no fallback to the administrative catalog.refactor(cloud):CloudClientconstruction groundwork. No behaviour change.feat(cloud): the feature itself.src/cloud/access.rsis the core. The commit message walks through the flow and the safety properties: no redirects followed on the handshake, the code and verifier are scrubbed from server messages, a 30-second bound per HTTP operation, and no retries of filing or the exchange.Notes
docs/reference/authentication.mdunder an experimental heading, not in the README.main:failed_fresh_start_preserves_postgres_identity_without_polluting_clickhouse_selectionandfile_and_stdin_stop_on_error_and_preserve_psql_error_status.Note
High Risk
Touches OAuth identity, credential storage, PKCE secrets, and a new API-key issuance path—security-critical changes with a large new CLI surface area.
Overview
Adds an experimental
cloud accesscommand group (Cargo featureexperimental-access-negotiation, off in published builds) so users can list caller-assignable roles and obtain a human-approved, scoped API key without managing a long-lived key.The clickhouse-cloud-api crate gains Bearer-only
organization_assignable_roles_get_listwith newAssignableRole*transport types (distinct from the paginated adminorganization_roles_get_list), plus client/model tests and OpenAPI-analyzer allowlisting.The CLI wires
cloud access roles(OAuth identity, org resolution from memberships) andcloud access request(PKCE authorization code flow: loopback redirect listener, browser approval, token exchange, credential write). Handshake HTTP uses a no-redirect client, bounded timeouts, secret redaction, and strict validation of discovery/grant payloads.CloudClientadds OAuth-onlyfor_access,RequestAuth, and refined Bearer storage; normal API-key precedence is bypassed for these commands.CI runs clippy/tests with the feature enabled; docs describe the flow under an experimental heading in
authentication.md.Reviewed by Cursor Bugbot for commit 825f81d. Bugbot is set up for automated code reviews on this repo. Configure here.