Cache

Struct Cache 

Source
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

Source

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.

Source

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.

Source

pub fn get_latest_key_id(&self) -> String

Retrieve the latest key id

Source

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.

Source

pub fn get_key_ids(&self) -> HashSet<String>

Get the current list of trusted key IDs.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.