NLnetLabs / krill

RPKI Certificate Authority and Publication Server written in Rust
https://nlnetlabs.nl/projects/routing/krill/
Mozilla Public License 2.0
297 stars 42 forks source link

Create new client if old client is older than 60 s #1226

Closed Koenvh1 closed 4 months ago

Koenvh1 commented 4 months ago

Based on https://github.com/ramosbugs/openidconnect-rs/issues/152 and some discussions with @partim , it seems like the OpenID connect client does not automatically rediscover anything, leading to login loops when e.g. the JWKs are rolled (as the signature can no longer be verified).

2024-06-27 10:29:15 [WARN] OpenID Connect: ID token verification failed: Signature verification failed [additional info: caused by: Signature verification failed, caused by: No matching key found]

This PR adds an explicit lifetime to the connection, and if the connection has existed for more than 60 seconds, it will initialise a new client. This is a tradeoff between doing rediscovery on every request (so requesting the /.well-known/openid-configuration endpoint, the jwk_uri inside that, and then the endpoint for the userinfo), which might slow things down on grouped requests, whilst also reasonably quickly learning about configuration changes.

The 60 seconds is arbitrary, and it might be nicer to make this configurable or document it somehow. Even nicer would be to honour the cache lifetimes of the HTTP responses, but I am not sure whether that is worth the effort.