Extension of tenduke::jwk::JWKSSignatureValidator, which first looks up key in cache, and if not found, tries to refresh the cache.
The cache is also refreshed, if the JWT has no "kid"-claim and the only cached key does not verify the signature: The IdP may have rotated the key (e.g. older backends, which do not set "kid").
The refresh replaces the cached keys with the downloaded key set, so keys removed by the IdP are no longer trusted. The refreshes are rate limited: after a refresh, the cache is not refreshed again for minRefreshIntervalS seconds, and the key is not found. Concurrent lookups share one refresh.
NOTE: Downloading the keyset may fail for various reasons (no network connection, invalid URL, temporary backend errors etc.), these cause tenduke::jwt::JWTValidationException, with the original exception nested.
|
| | DynamicJWKSSignatureValidator (const std::shared_ptr< tenduke::jwk::JWKS > &keySet, const std::shared_ptr< const tenduke::jwk::JWKSDownloader > &jwksDownloader, std::string jwksUrl, const std::shared_ptr< const tenduke::time::Clock > &clock, ::tenduke::crypto::HashAlgorithm validationAlgorithm=::tenduke::crypto::HashAlgorithm::NONE, std::int64_t minRefreshIntervalS=DEFAULT_MIN_REFRESH_INTERVAL_S) |
| | Constructs new instance.
|
| | JWKSSignatureValidator (const std::shared_ptr< tenduke::jwk::JWKS > &keySet, ::tenduke::crypto::HashAlgorithm validationAlgorithm=::tenduke::crypto::HashAlgorithm::NONE) |
| | Constructs new instance.
|
| bool | validate (const tenduke::json::JSONObject *jwtHeader, const char *payload, std::size_t payloadLength, const unsigned char *signatureBytes, std::size_t signatureLengthB) const override |
| | Validates JWT signature.
|
| std::vector< std::shared_ptr< const tenduke::crypto::PublicKey > > | getVerificationKeys () const override |
| | Returns the keys in the key set, which are usable for verifying signatures with the validation algorithm.
|
|
| std::unique_ptr< tenduke::jwk::JWK > | findJWK (const std::string &keyId) const override |
| | Locates the key from cache by id.
|
| std::unique_ptr< tenduke::jwk::JWK > | findRotatedJWK (const tenduke::jwk::JWK &rejectedKey) const override |
| | Refreshes the cache (unless refreshed within minRefreshIntervalS) and returns the only cached key usable for signatures, if it is not the rejected key.
|
|
virtual void | mergeKeys (const tenduke::jwk::JWKS &newKeySet) const |
| | Merges keys from newKeySet to the contained keySet.
|
|
virtual void | replaceKeys (const tenduke::jwk::JWKS &newKeySet) const |
| | Replaces keys of the contained keySet with the keys from newKeySet.
|