|
PACS System 0.1.0
PACS DICOM system library
|
#include <jwks_provider.h>

Public Member Functions | |
| jwks_provider () | |
| bool | load_from_json (std::string_view jwks_json) |
| Load keys from a JWKS JSON string. | |
| void | set_fetcher (jwks_fetch_callback fetcher) |
| Set a callback for fetching JWKS from a URL. | |
| void | set_jwks_url (const std::string &url) |
| Set the JWKS endpoint URL for fetching. | |
| std::optional< jwk_key > | get_key (std::string_view kid) const |
| Get a key by Key ID (kid) | |
| std::optional< jwk_key > | get_key_by_alg (std::string_view alg) const |
| Get the first key matching the given algorithm. | |
| bool | refresh () |
| Force refresh keys from the configured JWKS URL. | |
| const std::vector< jwk_key > & | keys () const |
| Get all currently loaded keys. | |
| void | set_cache_ttl (std::uint32_t seconds) |
| Set cache TTL in seconds (default: 3600) | |
| bool | is_cache_expired () const |
| Check if the cache has expired. | |
Private Member Functions | |
| bool | try_refresh () const |
Private Attributes | |
| std::vector< jwk_key > | keys_ |
| jwks_fetch_callback | fetcher_ |
| std::string | jwks_url_ |
| std::uint32_t | cache_ttl_seconds_ {3600} |
| std::chrono::steady_clock::time_point | last_fetch_ {} |
| std::mutex | mutex_ |
Definition at line 68 of file jwks_provider.h.
|
default |
|
nodiscard |
Get a key by Key ID (kid)
If keys are not loaded or cache has expired, attempts to refresh using the configured fetcher and JWKS URL.
| kid | Key ID to look up |
Definition at line 260 of file jwks_provider.cpp.
References fetcher_, is_cache_expired(), jwks_url_, keys_, mutex_, and try_refresh().

|
nodiscard |
Get the first key matching the given algorithm.
| alg | Algorithm name (e.g., "RS256") |
Definition at line 274 of file jwks_provider.cpp.
References fetcher_, is_cache_expired(), jwks_url_, keys_, mutex_, and try_refresh().

|
nodiscard |
Check if the cache has expired.
Definition at line 301 of file jwks_provider.cpp.
References cache_ttl_seconds_, and last_fetch_.
Referenced by get_key(), and get_key_by_alg().

|
nodiscard |
| bool kcenon::pacs::web::auth::jwks_provider::load_from_json | ( | std::string_view | jwks_json | ) |
Load keys from a JWKS JSON string.
Parses the JWKS JSON and converts JWK keys to PEM format. Replaces any previously loaded keys.
| jwks_json | JSON string containing {"keys": [...]} |
Definition at line 227 of file jwks_provider.cpp.
References keys_, last_fetch_, and mutex_.
| bool kcenon::pacs::web::auth::jwks_provider::refresh | ( | ) |
Force refresh keys from the configured JWKS URL.
Definition at line 288 of file jwks_provider.cpp.
References mutex_, and try_refresh().

| void kcenon::pacs::web::auth::jwks_provider::set_cache_ttl | ( | std::uint32_t | seconds | ) |
Set cache TTL in seconds (default: 3600)
Definition at line 297 of file jwks_provider.cpp.
References cache_ttl_seconds_.
| void kcenon::pacs::web::auth::jwks_provider::set_fetcher | ( | jwks_fetch_callback | fetcher | ) |
Set a callback for fetching JWKS from a URL.
| fetcher | Callback that receives URL and returns JSON body |
Definition at line 250 of file jwks_provider.cpp.
| void kcenon::pacs::web::auth::jwks_provider::set_jwks_url | ( | const std::string & | url | ) |
Set the JWKS endpoint URL for fetching.
| url | JWKS endpoint URL |
Definition at line 255 of file jwks_provider.cpp.
|
private |
Definition at line 308 of file jwks_provider.cpp.
References fetcher_, jwks_url_, keys_, and last_fetch_.
Referenced by get_key(), get_key_by_alg(), and refresh().

|
private |
Definition at line 140 of file jwks_provider.h.
Referenced by is_cache_expired(), and set_cache_ttl().
|
private |
Definition at line 138 of file jwks_provider.h.
Referenced by get_key(), get_key_by_alg(), set_fetcher(), and try_refresh().
|
private |
Definition at line 139 of file jwks_provider.h.
Referenced by get_key(), get_key_by_alg(), set_jwks_url(), and try_refresh().
|
mutableprivate |
Definition at line 137 of file jwks_provider.h.
Referenced by get_key(), get_key_by_alg(), keys(), load_from_json(), and try_refresh().
|
mutableprivate |
Definition at line 141 of file jwks_provider.h.
Referenced by is_cache_expired(), load_from_json(), and try_refresh().
|
mutableprivate |
Definition at line 142 of file jwks_provider.h.
Referenced by get_key(), get_key_by_alg(), load_from_json(), refresh(), set_fetcher(), and set_jwks_url().