fix(auth): accept ea_* prefix in isApiKey — unblocks static-bearer path for #28#31
Merged
stackbilt-admin merged 1 commit intomainfrom Apr 11, 2026
Merged
fix(auth): accept ea_* prefix in isApiKey — unblocks static-bearer path for #28#31stackbilt-admin merged 1 commit intomainfrom
stackbilt-admin merged 1 commit intomainfrom
Conversation
…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>
This was referenced Apr 11, 2026
Closed
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.
Summary
Small, surgical fix.
isApiKey()insrc/auth.tspreviously only matched the legacysb_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 mintingea_*keys, this check was never updated — so anyea_*bearer would fall through to thevalidateJwtpath and fail, leavingea_*API keys effectively unreachable through the gateway.This PR adds the
ea_*prefix to the check. Purely additive — no functional change for existingsb_*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 recognizeea_*tokens as API keys at all.Immediate unblock path after this merges + deploys:
ea_*key from edge-auth with explicit['read', 'generate']scopes.mcp.jsonas the Stackbilt MCP static bearerGotcha:
validateBearerTokenatauth.ts:53passesscopes: 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
resolveAuthis still needed for pre-2026-04-10 grants that have stale encrypted props.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— cleanea_*key, callimage_list_modelsthrough the gateway — confirm it returns model list (not(none)scopes error)Alignment
Aligns with edge-auth's own
resolvePrincipalatsrc/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
256ba06— C-1a remediation that created this gap