Skip to content

fix(auth): accept ea_* prefix in isApiKey — unblocks static-bearer path for #28#31

Merged
stackbilt-admin merged 1 commit intomainfrom
fix/auth-ea-prefix
Apr 11, 2026
Merged

fix(auth): accept ea_* prefix in isApiKey — unblocks static-bearer path for #28#31
stackbilt-admin merged 1 commit intomainfrom
fix/auth-ea-prefix

Conversation

@stackbilt-admin
Copy link
Copy Markdown
Member

Summary

Small, surgical fix. isApiKey() in src/auth.ts previously only matched the legacy sb_live_* / sb_test_* prefixes from the pre-migration stackbilt-auth era. When edge-auth took over as the ecosystem auth source of truth and started minting ea_* keys, this check was never updated — so any ea_* bearer would fall through to the validateJwt path and fail, leaving ea_* API keys effectively unreachable through the gateway.

This PR adds the ea_* prefix to the check. Purely additive — no functional change for existing sb_* keys.

Why now

This unblocks the Option B (static bearer bypass) path for the OAuth scope cluster tracked in #28/#29/#30. Currently every Claude Code / Claude.ai MCP session is silently locked out because OAuth-initiated tokens ship with empty scopes (C-1a remediation side effect). Before this merges, the ea_* fallback to edge-auth-minted API keys is impossible — the gateway literally can't recognize ea_* tokens as API keys at all.

Immediate unblock path after this merges + deploys:

  1. Mint an ea_* key from edge-auth with explicit ['read', 'generate'] scopes
  2. Drop into .mcp.json as the Stackbilt MCP static bearer
  3. Skip the OAuth flow entirely, reach the tools directly via the API key path

Gotcha: validateBearerToken at auth.ts:53 passes scopes: result.scopes ?? [] — if edge-auth mints the key with empty scopes, Option B hits the same (none) wall from a different code path. Confirm the minted key has explicit scopes before dropping it in the config.

What this does NOT fix

Both of those land as separate PRs. This one exists to stop the bleeding for API-key users today while the bigger fixes cook.

Test plan

  • npm run test — 120/120 green (6 files, includes auth.test.ts)
  • npm run typecheck — clean
  • Smoke: deploy, mint a test ea_* key, call image_list_models through the gateway — confirm it returns model list (not (none) scopes error)

Alignment

Aligns with edge-auth's own resolvePrincipal at src/security/identity.ts:44, which already accepts all three prefixes (ea_, sb_live_, sb_test_). This PR brings the gateway in line with the downstream SoT.

Related

…uth migration

The isApiKey() prefix sniffer only matched sb_live_*/sb_test_*, the legacy
stackbilt-auth key format. When edge-auth took over as the ecosystem auth
SoT and started minting ea_* keys, this check was never updated — so any
ea_* bearer would fall through to the validateJwt path and fail, leaving
ea_* API keys effectively unreachable through the gateway.

Aligns with edge-auth's own resolvePrincipal at src/security/identity.ts:44,
which already accepts all three prefixes. No functional change for existing
sb_* keys; purely additive.

Closes #28 partially — OAuth default-scope
fix still pending as Option A in that issue.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@stackbilt-admin stackbilt-admin merged commit a2c0fc9 into main Apr 11, 2026
1 check passed
@stackbilt-admin stackbilt-admin deleted the fix/auth-ea-prefix branch April 11, 2026 20:33
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