nginxinc / kubernetes-ingress

NGINX and NGINX Plus Ingress Controllers for Kubernetes
https://docs.nginx.com/nginx-ingress-controller
Apache License 2.0
4.68k stars 1.97k forks source link

Ability to validate claims in JWT policy #6829

Open anderius opened 6 days ago

anderius commented 6 days ago

Currently, we must use snippets to validate claims in the validated JWT.

It would be very nice if we could validate custom claims, for example scope, directly from the JWT policy (https://docs.nginx.com/nginx-ingress-controller/configuration/policy-resource/#jwt-using-jwks-from-remote-location).

As an example of how this cane be done, see https://learn.microsoft.com/en-us/azure/api-management/validate-jwt-policy.

From that link (of course I don't want XML, but you get the idea :-) ):

 <required-claims>
    <claim name="name of the claim as it appears in the token" match="all | any" separator="separator character in a multi-valued claim">
      <value>claim value as it is expected to appear in the token</value>
      <!-- if there is more than one allowed value, then add additional value elements -->
    </claim>
    <!-- if there are multiple possible allowed claim, then add additional claim elements -->
  </required-claims>
github-actions[bot] commented 6 days ago

Hi @anderius thanks for reporting!

Be sure to check out the docs and the Contributing Guidelines while you wait for a human to take a look at this :slightly_smiling_face:

Cheers!

jasonwilliams14 commented 6 days ago

@anderius I believe this is what you are looking for? This capability in NGINX Ingress controller:

https://github.com/nginxinc/kubernetes-ingress/discussions/4417

anderius commented 5 days ago

Thank you, I was not aware of that discussion. Would you prefer to have feature requests there instead of issues?

A few points: