Implement io.jwt.verify_eddsa builtin (closes #145) - #153
Conversation
Signed-off-by: Muhammad Umer Hammad <umerhammad010@gmail.com>
| type = "string", | ||
| name = "certificate", | ||
| description = | ||
| "PEM encoded certificate, PEM encoded public key, or the JWK key (set) used to verify the signature") |
There was a problem hiding this comment.
_verifyEdDSA reaches getPublicKey → extractPublicKey, which only handles RSAKey and ECKey. An Ed25519 JWK parses to an OctetKeyPair (kty: OKP), so it falls into the else branch and throws "Unsupported JWK key type" — meaning this returns false (or errors in strict mode) for a valid Ed25519 JWK, even though the arg doc here advertises "the JWK key (set)".
This diverges from OPA: its getKeysFromCertOrJWK (v1/topdown/tokens.go) parses JWKs via jwx's jwk.Export, which supports OKP keys, so OPA accepts an Ed25519 JWK for io.jwt.verify_eddsa. For parity, consider adding an OKP branch to extractPublicKey (convert OctetKeyPair → Ed25519 PublicKey) rather than only supporting the PEM path. The added test only covers the PEM cert fixture, so the JWK path is untested for EdDSA.
Signed-off-by: Muhammad Umer Hammad <umerhammad010@gmail.com>
The OKP branch added in 4fb00ae compiled on this branch's base, where TokenBuiltins used a wildcard `com.nimbusds.jose.jwk.*` import. Main has since expanded that wildcard (c75bba7, open-policy-agent#171) into explicit imports that do not cover Curve or OctetKeyPair, so the merge builds cleanly in git but fails javac. Add the two imports. The compliance ratchet added on main also needs io.jwt.verify_eddsa removed from known-missing-builtins.txt, since the builtin now resolves and the suite fails on stale entries. Squash before merge. Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
Summary
Implements io.jwt.verify_eddsa as described in #145.
Changes
Testing
Closes #145.