pub struct KeyStore { /* private fields */ }
Implementations§
Source§impl KeyStore
impl KeyStore
pub fn new() -> KeyStore
pub async fn new_from(jkws_url: &str) -> Result<KeyStore, Error>
pub fn clear_keys(&mut self)
pub fn key_set_url(&self) -> &str
pub async fn load_keys_from(&mut self, url: &str) -> Result<(), Error>
pub async fn load_keys(&mut self) -> Result<(), Error>
pub fn decode(&self, token: &str) -> Result<Jwt, Error>
pub fn verify_time(&self, token: &str, time: SystemTime) -> Result<Jwt, Error>
Sourcepub fn verify(&self, token: &str) -> Result<Jwt, Error>
pub fn verify(&self, token: &str) -> Result<Jwt, Error>
Verify a JWT token. If the token is valid, it is returned.
A token is considered valid if:
- Is well formed
- Has a
kid
field that matches a public signature `kid - Signature matches public key
- It is not expired
- The
nbf
is not set to before now
Sourcepub fn last_load_time(&self) -> Option<SystemTime>
pub fn last_load_time(&self) -> Option<SystemTime>
Time at which the keys were last refreshed
Sourcepub fn keys_expired(&self) -> Option<bool>
pub fn keys_expired(&self) -> Option<bool>
True if the keys are expired and should be refreshed
None if keys do not have an expiration time
Sourcepub fn set_refresh_interval(&mut self, interval: f64)
pub fn set_refresh_interval(&mut self, interval: f64)
Specifies the interval (as a fraction) when the key store should refresh it’s key.
The default is 0.5, meaning that keys should be refreshed when we are halfway through the expiration time (similar to DHCP).
This method does not update the refresh time. Call load_keys
to force an update on the refresh time property.
Sourcepub fn refresh_interval(&self) -> f64
pub fn refresh_interval(&self) -> f64
Get the current fraction time to check for token refresh time.
Sourcepub fn load_time(&self) -> Option<SystemTime>
pub fn load_time(&self) -> Option<SystemTime>
The time at which the keys were loaded
None if the keys were never loaded via load_keys
or load_keys_from
.
Sourcepub fn expire_time(&self) -> Option<SystemTime>
pub fn expire_time(&self) -> Option<SystemTime>
Get the time at which the keys are considered expired
Sourcepub fn refresh_time(&self) -> Option<SystemTime>
pub fn refresh_time(&self) -> Option<SystemTime>
time at which keys should be refreshed.
Sourcepub fn should_refresh_time(&self, current_time: SystemTime) -> Option<bool>
pub fn should_refresh_time(&self, current_time: SystemTime) -> Option<bool>
Returns Option<true>
if keys should be refreshed based on the given current_time
.
None is returned if the key store does not have a refresh time available. For example, the
load_keys
function was not called or the HTTP server did not provide a
Sourcepub fn should_refresh(&self) -> Option<bool>
pub fn should_refresh(&self) -> Option<bool>
Returns Option<true>
if keys should be refreshed based on the system time.
None is returned if the key store does not have a refresh time available. For example, the
load_keys
function was not called or the HTTP server did not provide a