pub struct Cache { /* private fields */ }Expand description
Maintains the autoritative list of currently trusted JWKs for a single team and caches the DecodingKey structs derived from them. Needs to be periodically seeded with latest keys by some external trigger invoking the rotate_keys() method.
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn new(latest_key_id: &str, keymap: AccessKeyMap) -> Self
pub fn new(latest_key_id: &str, keymap: AccessKeyMap) -> Self
Constructs a new Cache from a key ID denoting the latest JWK and a HashMap of key IDs to AccessKey structs.
Sourcepub fn is_rotation_needed(&self, candidate_key_ids: HashSet<String>) -> bool
pub fn is_rotation_needed(&self, candidate_key_ids: HashSet<String>) -> bool
Given a specific map of new keys, check if an update is required.
Sourcepub fn get_latest_key_id(&self) -> String
pub fn get_latest_key_id(&self) -> String
Retrieve the latest key id
Sourcepub fn rotate_keys(&self, latest_key_id: &str, latest_keymap: AccessKeyMap)
pub fn rotate_keys(&self, latest_key_id: &str, latest_keymap: AccessKeyMap)
Updates the Cache with a new latest key ID and map of AccessKey structs.
Sourcepub fn get_key_ids(&self) -> HashSet<String>
pub fn get_key_ids(&self) -> HashSet<String>
Get the current list of trusted key IDs.
Sourcepub fn get_decoding_key(&self, key_id: &str) -> Option<DecodingKey>
pub fn get_decoding_key(&self, key_id: &str) -> Option<DecodingKey>
Attempt to retrieve a specific key as a DecodingKey struct.
Auto Trait Implementations§
impl !Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnwindSafe for Cache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more