Class JwksOptions
java.lang.Object
com.jsgalactic.axiom.security.jwt.JwksOptions
Bounds and timings for a JSON Web Key Set used by
JwtAuthenticator, set with JwtAuthenticator.Builder.jwks(JwksSource, JwksOptions). Immutable; every method returns a
changed copy.
| Setting | Default | Range | Meaning |
|---|---|---|---|
maxBytes | 64 KiB | 1 KiB to 1 MiB | longest accepted document; at most 100 keys |
refreshInterval | 10 minutes | 1 second to 24 hours | age after which the set is refetched |
minRefreshInterval | 30 seconds | 1 second to the refresh interval | shortest time between fetch attempts, successful or not |
maxStale | 24 hours | the refresh interval to 7 days | how long the last good set stays usable while fetches fail |
defaultAlgorithm | none | - | algorithm for keys that declare no alg |
-
Method Summary
Modifier and TypeMethodDescriptiondefaultAlgorithm(JwsAlgorithm algorithm) Sets the algorithm for keys of the set that declare noalg(some issuers omit it).static JwksOptionsdefaults()Returns the default settings.maxBytes(int bytes) Sets the longest accepted key set document.Sets how long a key set stays usable after its last successful fetch while later fetches fail.minRefreshInterval(Duration interval) Sets the shortest time between two fetch attempts, successful or not.refreshInterval(Duration interval) Sets the age after which the next token triggers a refetch.
-
Method Details
-
defaults
Returns the default settings.- Returns:
- the defaults
-
maxBytes
Sets the longest accepted key set document.- Parameters:
bytes- 1,024 to 1,048,576- Returns:
- a changed copy
-
refreshInterval
Sets the age after which the next token triggers a refetch. Tokens keep being verified with the previous set while the refetch is running or failing.- Parameters:
interval- 1 second to 24 hours, whole seconds- Returns:
- a changed copy
-
minRefreshInterval
Sets the shortest time between two fetch attempts, successful or not. It bounds the load a stream of tokens with unknown key IDs can put on the key set endpoint, and the retry rate while the endpoint fails.- Parameters:
interval- 1 second up to the refresh interval, whole seconds- Returns:
- a changed copy
-
maxStale
Sets how long a key set stays usable after its last successful fetch while later fetches fail. After that no key of the set verifies a token (fail closed), so a revoked key cannot outlive an unreachable endpoint forever.- Parameters:
age- the refresh interval up to 7 days, whole seconds- Returns:
- a changed copy
-
defaultAlgorithm
Sets the algorithm for keys of the set that declare noalg(some issuers omit it). Without it such keys are skipped, because an RSA key alone does not say whether it is meant for RS256 or PS256. The algorithm must fit the key type; a key of another type is skipped. A key that declares analgalways keeps its own.- Parameters:
algorithm- an RS, PS, ES or EdDSA algorithm- Returns:
- a changed copy
-