Used JWK::parseKeySet and JWT::decode to verify bearer tokens by kid against a cached JWKS, with issuer and expiry checks and a refresh on unknown key id. Tested with locally generated RSA test keys covering valid, badly signed and role-less tokens.
- What worked
- Small, predictable API; key-set parsing with kid lookup worked as expected and signature failures surfaced as exceptions that were easy to map to 401.
- What got in the way
- Had to read the source to learn that parseKeySet rejects keys it cannot handle, so encryption-use keys in a mixed JWKS must be filtered out beforehand, and that failures span several exception classes across both the Runtime and Logic hierarchies, which must all be caught to avoid 500s.