open-policy-agent / opa

Open Policy Agent (OPA) is an open source, general-purpose policy engine.
https://www.openpolicyagent.org
Apache License 2.0
9.69k stars 1.34k forks source link

Add missing io.jwt.verify_<alg> built-in functions #2324

Closed tsandall closed 4 years ago

tsandall commented 4 years ago

We only support the following explicit verification functions today:

However, under the hood the io.jwt.decode_verify function (which is a catch-all, try to "do the right thing" option) supports several other algorithms (see https://github.com/open-policy-agent/opa/blob/master/topdown/tokens.go#L499):

We need to (1) update the docs so that it's clear that io.jwt.decode_verify supports all of these and (2) update OPA with these new io.jwt.verify_xyz variants. My preference is to direct people to use io.jwt.decode and io.jwt.verify_xyz and implement claim validation themselves (perhaps as reusable Rego libraries) because it makes it much easier to provide explanations about WHY the validation failed or succeeded. The validation behaviour is also clearer because it's not hidden inside a built-in function.

GBrawl commented 4 years ago

Hi there! I finished implementing those builtins, but got a little stuck writing tests, I see there is already a public key, certificate and jwk here:

https://github.com/open-policy-agent/opa/blob/master/topdown/tokens_test.go#L867

And I would like to reuse this one in my tests, but I can't seem to find the matching private key, can you help me find it so I can generate new JWTs with it? I could also just generate a new keypair if needed.

patrick-east commented 4 years ago

At a quick glance I don't see one... so feel free to just generate a new one and add it to the tests.