Skip to content

fix: accept EOA-subject admin keys in legacy VerifyJwtKeyForUser#515

Merged
chrisli30 merged 1 commit into
stagingfrom
fix/legacy-verify-jwt-eoa-admin
Apr 9, 2026
Merged

fix: accept EOA-subject admin keys in legacy VerifyJwtKeyForUser#515
chrisli30 merged 1 commit into
stagingfrom
fix/legacy-verify-jwt-eoa-admin

Conversation

@chrisli30
Copy link
Copy Markdown
Member

Summary

Follow-up to #513. The audience-claim fix unblocked the modern verifier, but GetKey (used by SDK authWithAPIKey) calls VerifyJwtKeyForUser in core/auth/user.go, which had two bugs:

  1. Only treated literal sub == "apikey" as admin, but release: staging → main (event trigger fixes, fee classification, JWT API key, sentry logging) #509 changed CreateAdminKey to require an EOA address as the subject.
  2. For EOA-subject JWTs, even when claimAddress == userWallet, fell through to Malform JWT Key Claim because the address-match branch was missing a return true, nil.

Add an EOA-subject branch mirroring the modern verifyAuth contract: admin-role keys may manage any wallet; non-admin keys are valid only when subject == userWallet.

Discovered re-running ava-sdk-js#209 CI after #513 merged — the API key length grew (proving aud was now embedded) but tests/core/auth.test.ts still failed against this legacy path.

Test plan

GetKey (the API key exchange handler used by SDK authWithAPIKey) calls
VerifyJwtKeyForUser, which had two bugs that combined to reject every
key generated by the modern create-api-key CLI:

1. It only treated the literal string "apikey" as an admin subject,
   but PR #509 changed CreateAdminKey to require an EOA address as
   the JWT subject — so admin keys never matched the role-based path.
2. For EOA-subject JWTs, even when claimAddress == userWallet, the
   function fell through to "Malform JWT Key Claim" because the
   address-match branch was missing a `return true, nil`.

Add an EOA-subject branch that mirrors the modern verifyAuth contract:
admin-role keys may manage any wallet; non-admin keys are valid only
when subject == userWallet.

Discovered while debugging AvaProtocol/ava-sdk-js#209 CI failures.
@chrisli30 chrisli30 merged commit 272c320 into staging Apr 9, 2026
4 of 5 checks passed
chrisli30 added a commit that referenced this pull request Apr 10, 2026
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.

2 participants