Skip to content

Commit a2c0fc9

Browse files
stackbilt-adminKurt Overmierclaude
authored
fix(auth): accept ea_* prefix in isApiKey — staleness bug from edge-auth migration (#31)
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: Kurt Overmier <kurt@stackbilt.dev> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9fd96f8 commit a2c0fc9

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/auth.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55
import type { AuthResult, AuthServiceRpc, Tier } from './types.js';
66

77
function isApiKey(token: string): boolean {
8-
return token.startsWith('sb_live_') || token.startsWith('sb_test_');
8+
// Must match edge-auth's `resolvePrincipal` / `extractKeyPrefix` — edge-auth
9+
// is the SoT for key format. The old `sb_*` checks are legacy from the
10+
// pre-migration stackbilt-auth era and were never updated when edge-auth
11+
// took over and started minting `ea_*` keys.
12+
return (
13+
token.startsWith('ea_') ||
14+
token.startsWith('sb_live_') ||
15+
token.startsWith('sb_test_')
16+
);
917
}
1018

1119
function mapError(error?: string): string {

0 commit comments

Comments
 (0)