Refresh JWK when token contains unknown kid #7414
Labels
area/security
Issues related to security capabilities or concerns
proposal
An issue that proposes a feature request
ready for refinement
An issue that was triaged and it is ready to be refined
Is your feature request related to a problem? Please describe.
We have a problem using the JWT policy (https://docs.nginx.com/nginx-ingress-controller/configuration/policy-resource/#jwt-using-jwks-from-remote-location), when the IdP rotates the key, and starts to use the new key BEFORE the caching has expired.
Describe the solution you'd like
A recommended, and very common, way to do this, is to fetch a the JWKS when the key (kid) is not found. This is recommended for example by EntraID:
https://learn.microsoft.com/en-us/entra/identity-platform/signing-key-rollover#best-practices-for-keys-metadata-caching-and-validation
The keys should be refreshed:
Describe alternatives you've considered
Setting a very short cache time is possible, but would not be failsafe. IdPs usualle (like EntraID) have documented that they might rotate the keys very fast, when security requires it.
Additional context
Using Nginx Ingress Controller 4.0.1.
The problem is experienced with an internal IdP that rotate keys often, but the principle is valid for all IdPs.
The text was updated successfully, but these errors were encountered: