pub struct TokenMap<G: TagGrant = Box<dyn TagGrant + Send + Sync + 'static>> { /* private fields */ }Expand description
Keeps track of access and refresh tokens by a hash-map.
The generator is itself trait based and can be chosen during construction. It is assumed to not be possible (or at least very unlikely during their overlapping lifetime) for two different grants to generate the same token in the grant tagger.
Implementations§
Source§impl<G: TagGrant> TokenMap<G>
impl<G: TagGrant> TokenMap<G>
Sourcepub fn valid_for(&mut self, duration: Duration)
pub fn valid_for(&mut self, duration: Duration)
Set the validity of all issued grants to the specified duration.
Sourcepub fn valid_for_default(&mut self)
pub fn valid_for_default(&mut self)
All grants are valid for their default duration.
Sourcepub fn revoke(&mut self, token: &str)
pub fn revoke(&mut self, token: &str)
Unconditionally delete grant associated with the token.
This is the main advantage over signing tokens. By keeping internal state of allowed grants, the resource owner or other instances can revoke a token before it expires naturally. There is no differentiation between access and refresh tokens since these should have a marginal probability of colliding.
Sourcepub fn import_grant(&mut self, token: String, grant: Grant)
pub fn import_grant(&mut self, token: String, grant: Grant)
Directly associate token with grant.
No checks on the validity of the grant are performed but the expiration time of the grant
is modified (if a duration was previously set).