Skip to content

promote: org tokens workspace scope + docs - #1108

Merged
HongmingWang-Rabbit merged 2 commits into
mainfrom
staging
Apr 20, 2026
Merged

HongmingWang-Rabbit merged 2 commits into
mainfrom
staging

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

promote

Hongming Wang and others added 2 commits April 20, 2026 14:11
Extends WorkspaceAuth to accept org API tokens as a valid
credential for any workspace sub-route in the org. Previously a
user minting an org token could hit admin-surface endpoints
(/workspaces, /org/import, etc.) but couldn't reach per-workspace
routes like /workspaces/:id/channels — those were gated by
WorkspaceAuth which only knew about workspace-scoped tokens.

Scope matches the explicit product spec: one org API key can
manipulate every workspace in the org. AI agents given a key can
read/write channels, tokens, schedules, secrets, tasks across all
workspaces.

## WorkspaceAuth tier order

  1. ADMIN_TOKEN exact match (break-glass / bootstrap)
  2. Org API token (Validate against org_api_tokens)           NEW
  3. Workspace-scoped token (ValidateToken with :id binding)
  4. Same-origin canvas referer

Org token tier sits above the per-workspace check so a presenter
of an org key doesn't hit the narrower ValidateToken failure path
first. Checked with isSameOriginCanvas path unchanged.

## End-to-end verified

Minted test token via ADMIN_TOKEN, then with that org token:
  - GET /workspaces             → 200 (list all)
  - GET /workspaces/<id>        → 200 (detail, admin-only route)
  - GET /workspaces/<id>/channels → 200 (workspace sub-route)
  - GET /workspaces/<id>/tokens   → 200 (workspace tokens list)
  - GET /workspaces/<bad-uuid>    → 404 workspace not found
                                    (routing still scoped correctly)

## Documentation

  - docs/architecture/org-api-keys.md — design, data model, threat
    model, security properties
  - docs/architecture/org-api-keys-followups.md — 10 tracked
    follow-ups prioritized (role scoping P1, per-workspace binding
    P1, expiry P2, usage metrics P2, WorkOS user_id capture P2,
    rotation webhooks P3, mint-rate limit P3, audit log P2, CLI
    P3, migrate ADMIN_TOKEN to the same table P4)
  - docs/guides/org-api-keys.md — end-user guide (mint via UI,
    use in curl/Python/TS/AI agents, session-vs-key comparison)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
feat(auth): org tokens reach workspace subroutes + docs
@HongmingWang-Rabbit
HongmingWang-Rabbit merged commit a981673 into main Apr 20, 2026
4 of 7 checks passed
molecule-ai Bot pushed a commit that referenced this pull request Apr 21, 2026
promote: org tokens workspace scope + docs
HongmingWang-Rabbit pushed a commit that referenced this pull request Jun 12, 2026
Invalid JSON in channel_config or allowed_users previously left the
corresponding variables nil, causing downstream nil-pointer risks.

- Set config to empty map on unmarshal failure\n- Set allowed_users to empty slice on unmarshal failure\n- Add tests covering invalid JSON in both List and Webhook paths\n\nCloses #1108
HongmingWang-Rabbit pushed a commit that referenced this pull request Jun 12, 2026
…arshal errors (#1108)' (#2347) from fix/channels-unmarshal-fallback-invalid-json into main

2 genuine officials current head + 3 required contexts green, mergeable; force past non-required governance/staging red (merge-queue-bug workaround until #2349). CTO diff-reviewed.
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