Skip to content

fix(server): single source of truth for RPC authorization scopes - #220

Merged
patroza merged 1 commit into
fork/changesfrom
fix/rpc-auth-single-source
Jul 30, 2026
Merged

fix(server): single source of truth for RPC authorization scopes#220
patroza merged 1 commit into
fork/changesfrom
fix/rpc-auth-single-source

Conversation

@patroza

@patroza patroza commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Runtime WS auth was reading a second scope table (RPC_REQUIRED_SCOPE Map in ws.ts) while the typed single source of truth lives in auth/RpcAuthorization.ts (RPC_REQUIRED_SCOPES / requiredScopeForRpcMethod).
  • Identity RPCs (identity.getSessionClaim, etc.) were registered only in the typed table, so clients failed with: Could not load identity — RPC method identity.getSessionClaim has no declared authorization scope.
  • The Map also drifted elsewhere (e.g. cloudGetRelayClientStatus was AuthRelayWriteScope in the Map vs AuthRelayReadScope in the typed table).
  • Fix: delete the Map; route all observeRpc* authorization through requiredScopeForRpcMethod. Add a test that every WsRpcGroup method resolves via that helper.

Why this was easy to re-break

Identity overlay already imported requiredScopeForRpcMethod but never used it — the runtime path stayed on the stale Map.

Deploy note

After merge into fork/changes, Compose should auto-rebase fork/identity (which already has identity scopes in RPC_REQUIRED_SCOPES). Once integration picks up the rebased tip, the identity claim UI error goes away.

Test plan

  • vp test run apps/server/src/auth/RpcAuthorization.test.ts
  • vp check
  • full monorepo typecheck
  • After merge + compose + deploy: open web client → identity claim loads without the authorization-scope error
  • Spot-check relay status still works with read scope (no install requirement for status alone)

opened by Patrick Roza in chat thread Discord · 🔀 Add Thread Source Attribution Filters · T3

ws.ts kept a parallel RPC_REQUIRED_SCOPE Map while RpcAuthorization.ts
owned the typed RPC_REQUIRED_SCOPES table. Identity methods were added
only to the typed table, so production failed with "has no declared
authorization scope" for identity.getSessionClaim.

Route observeRpc* through requiredScopeForRpcMethod and drop the Map.
@patroza
patroza merged commit e31e03d into fork/changes Jul 30, 2026
8 checks passed
patroza added a commit that referenced this pull request Jul 30, 2026
ws.ts kept a parallel RPC_REQUIRED_SCOPE Map while RpcAuthorization.ts
owned the typed RPC_REQUIRED_SCOPES table. Identity methods were added
only to the typed table, so production failed with "has no declared
authorization scope" for identity.getSessionClaim.

Route observeRpc* through requiredScopeForRpcMethod and drop the Map.

Co-authored-by: T3 Code PR Stack <41898282+github-actions[bot]@users.noreply.github.com>
patroza added a commit that referenced this pull request Jul 30, 2026
ws.ts kept a parallel RPC_REQUIRED_SCOPE Map while RpcAuthorization.ts
owned the typed RPC_REQUIRED_SCOPES table. Identity methods were added
only to the typed table, so production failed with "has no declared
authorization scope" for identity.getSessionClaim.

Route observeRpc* through requiredScopeForRpcMethod and drop the Map.

Co-authored-by: T3 Code PR Stack <41898282+github-actions[bot]@users.noreply.github.com>
patroza added a commit that referenced this pull request Jul 30, 2026
ws.ts kept a parallel RPC_REQUIRED_SCOPE Map while RpcAuthorization.ts
owned the typed RPC_REQUIRED_SCOPES table. Identity methods were added
only to the typed table, so production failed with "has no declared
authorization scope" for identity.getSessionClaim.

Route observeRpc* through requiredScopeForRpcMethod and drop the Map.

Co-authored-by: T3 Code PR Stack <41898282+github-actions[bot]@users.noreply.github.com>
patroza added a commit that referenced this pull request Jul 31, 2026
ws.ts kept a parallel RPC_REQUIRED_SCOPE Map while RpcAuthorization.ts
owned the typed RPC_REQUIRED_SCOPES table. Identity methods were added
only to the typed table, so production failed with "has no declared
authorization scope" for identity.getSessionClaim.

Route observeRpc* through requiredScopeForRpcMethod and drop the Map.

Co-authored-by: T3 Code PR Stack <41898282+github-actions[bot]@users.noreply.github.com>
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