fix: accept EOA-subject admin keys in legacy VerifyJwtKeyForUser#515
Merged
Conversation
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
added a commit
that referenced
this pull request
Apr 10, 2026
Co-authored-by: Wei Lin <wei@avaprotocol.org>
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
Follow-up to #513. The audience-claim fix unblocked the modern verifier, but
GetKey(used by SDKauthWithAPIKey) callsVerifyJwtKeyForUserincore/auth/user.go, which had two bugs:sub == "apikey"as admin, but release: staging → main (event trigger fixes, fee classification, JWT API key, sentry logging) #509 changedCreateAdminKeyto require an EOA address as the subject.claimAddress == userWallet, fell through toMalform JWT Key Claimbecause the address-match branch was missing areturn true, nil.Add an EOA-subject branch mirroring the modern
verifyAuthcontract: admin-role keys may manage any wallet; non-admin keys are valid only whensubject == userWallet.Discovered re-running ava-sdk-js#209 CI after #513 merged — the API key length grew (proving
audwas now embedded) buttests/core/auth.test.tsstill failed against this legacy path.Test plan
go build ./...cleantest:corepasses after a fresh:latestrebuild