⏱️ oidc: cache im's keys for ten minutes, so a withdrawn key stops verifying sooner
Browse files at this commita05110df60e044b8852ce0eea7ec15b7b9071589Parent: 1fa884b2 changed files +3 -3
- crates/in-web/src/oidc.rs +2 -2
- docs/contracts.md +1 -1
crates/in-web/src/oidc.rsmodified+2 -2
| @@ -1,7 +1,7 @@ | |||
| 1 | //! The OpenID Connect client of `in`, a relying party of `im` (docs/contracts.md section 2). | 1 | //! The OpenID Connect client of `in`, a relying party of `im` (docs/contracts.md section 2). |
| 2 | //! | 2 | //! |
| 3 | //! It does four things and nothing more. It finds `im`'s endpoints (discovery, cached, with the | 3 | //! It does four things and nothing more. It finds `im`'s endpoints (discovery, cached, with the |
| 4 | -//! standard paths as a fallback). It keeps `im`'s signing keys (JWKS, cached for an hour, refetched at | 4 | +//! standard paths as a fallback). It keeps `im`'s signing keys (JWKS, cached for ten minutes, refetched at |
| 5 | //! most once a minute when a token names an unknown key). It verifies the three kinds of token `in` | 5 | //! most once a minute when a token names an unknown key). It verifies the three kinds of token `in` |
| 6 | //! receives: ID tokens, logout tokens and access tokens. And it makes the calls `in` sends to `im`: the | 6 | //! receives: ID tokens, logout tokens and access tokens. And it makes the calls `in` sends to `im`: the |
| 7 | //! code exchange and the client-credentials token that the directory and the photos need. | 7 | //! code exchange and the client-credentials token that the directory and the photos need. |
| @@ -31,7 +31,7 @@ pub const CLOCK_LEEWAY_SECS: i64 = 60; | |||
| 31 | pub const MAX_FUTURE_IAT_SECS: i64 = 300; | 31 | pub const MAX_FUTURE_IAT_SECS: i64 = 300; |
| 32 | 32 | ||
| 33 | /// How long a fetched key set is used before it is fetched again (contracts section 2.2). | 33 | /// How long a fetched key set is used before it is fetched again (contracts section 2.2). |
| 34 | -pub const JWKS_MAX_AGE: Duration = Duration::from_secs(60 * 60); | 34 | +pub const JWKS_MAX_AGE: Duration = Duration::from_secs(10 * 60); |
| 35 | 35 | ||
| 36 | /// The shortest gap between two key fetches. A fetch for an unknown `kid`, and a retry after a failed | 36 | /// The shortest gap between two key fetches. A fetch for an unknown `kid`, and a retry after a failed |
| 37 | /// fetch, both wait this long. It is the one-minute refetch limit of contracts section 2.2, and it | 37 | /// fetch, both wait this long. It is the one-minute refetch limit of contracts section 2.2, and it |
docs/contracts.mdmodified+1 -1
| @@ -60,7 +60,7 @@ Clients fetch discovery once at boot and cache it. They may hard-code the paths | |||
| 60 | the last 7 days, as `{"kty":"OKP","crv":"Ed25519","x":...,"kid":...,"use":"sig","alg":"EdDSA"}`. | 60 | the last 7 days, as `{"kty":"OKP","crv":"Ed25519","x":...,"kid":...,"use":"sig","alg":"EdDSA"}`. |
| 61 | - `im` rotates the signing key every 90 days and on admin demand. A new key is published 24 hours before it | 61 | - `im` rotates the signing key every 90 days and on admin demand. A new key is published 24 hours before it |
| 62 | signs anything. | 62 | signs anything. |
| 63 | -- Clients cache the JWKS for 1 hour, and refetch at most once a minute when a token names an unknown `kid`. | 63 | +- Clients cache the JWKS for 10 minutes, and refetch at most once a minute when a token names an unknown `kid`. |
| 64 | 64 | ||
| 65 | ### 2.3 Sign-in (authorization code + PKCE) | 65 | ### 2.3 Sign-in (authorization code + PKCE) |
| 66 | 66 | ||