Skip to content

feat: act for a Connect user with ONE_CONNECT_USER_ID (v2.18.0) - #246

Open
paulkr wants to merge 1 commit into
mainfrom
feat/connect-grant
Open

paulkr wants to merge 1 commit into
mainfrom
feat/connect-grant

Conversation

@paulkr

@paulkr paulkr commented Nov 21, 2026

Copy link
Copy Markdown
Member

What this does

An app built on @withone/connect can now run the CLI as one of its users. Set ONE_SECRET to the app's Connect key and ONE_CONNECT_USER_ID to the user's cu_… id, in the env or .onerc.

  • Every request sends x-one-connect-user-id beside x-one-secret: API calls, knowledge loads and passthrough. One then holds the call to that user's grant, as it does for the SDK.
  • The header can't be overridden. It joins the identity headers that --headers and flow steps can't set, so nothing can switch the connected user mid-run.
  • one list reads /v1/connections/reachable under a grant. /v1/vault/connections, /v1/access/me and /v1/connections all refuse a grant. Each reachable row carries what the grant gives on it and the user's share level, so the listing shows the grant's access with accessSource: "server". Every other listConnections caller (flows, sync, find's platform list) reads the same route.
  • one whoami shows the connected user and connectUserId.
  • The cached whoami is keyed to the Connect user, the same way it's already keyed to the API base. A connected user is never reported as the config key's owner, or one Connect user as another.
  • Docs: README, one guide, the skill and --help. Version 2.18.0.

ONE_CONNECT_USER_ID is never written to config. One refuses a Connect key without it, and an ordinary key with it (GrantBearerRequired), so a stray value in a cloned .onerc makes calls fail rather than widen what a key reaches.

What a grant can run today

Command Route Under a grant
whoami /v1/users/whoami works
list /v1/connections/reachable works (this PR)
actions load /v1/knowledge works
actions execute /v1/passthrough works; an action outside the grant gets a 403
actions find /v1/available-actions/find refused by One until core accepts a grant there (separate pica PR)
add, remove, relays vault, relay routes refused; need an ordinary key

No CLI change is needed for find once core accepts a grant: it already sends the header.

Out of scope: Connect's token mode (a minted bearer). Its tokens are short-lived, so it doesn't fit a CLI config.

Checks

  • New tests: 7, in src/lib/connect-grant.test.ts. They cover:

    • the header on API, knowledge and passthrough calls, and no header for an ordinary key;
    • listConnections paging /connections/reachable;
    • a caller-supplied header being refused;
    • each grant policy mapping to the access one list shows;
    • env over .onerc;
    • the whoami cache following the Connect user.

    The header, listing and refusal tests fail without the change.

  • Full suite: 944 of 952 pass. The 6 failures are the resolveConfig tests, which fail the same way on a clean main on this machine. CI is green on main.

  • Typecheck and build: pass.

  • Not yet run live against dev with a real Connect key and cu_… id.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant