pub struct TokenRevocationManager { /* private fields */ }Expand description
High-level token revocation manager wrapping a backend store.
Implementations§
Source§impl TokenRevocationManager
impl TokenRevocationManager
Sourcepub fn new(
store: Arc<dyn RevocationStore>,
require_jti: bool,
fail_open: bool,
) -> Self
pub fn new( store: Arc<dyn RevocationStore>, require_jti: bool, fail_open: bool, ) -> Self
Create a new revocation manager.
Sourcepub async fn check_token(&self, jti: Option<&str>) -> Result<(), TokenRejection>
pub async fn check_token(&self, jti: Option<&str>) -> Result<(), TokenRejection>
Check if a token should be rejected.
Returns Ok(()) if the token is allowed, or an error reason if rejected.
§Errors
Returns TokenRejection::MissingJti if JTI is required but absent.
Returns TokenRejection::Revoked if the token has been revoked.
Returns TokenRejection::StoreUnavailable if the revocation store is unreachable and
fail_open is false.
Sourcepub async fn revoke(
&self,
jti: &str,
ttl_secs: u64,
) -> Result<(), RevocationError>
pub async fn revoke( &self, jti: &str, ttl_secs: u64, ) -> Result<(), RevocationError>
Revoke a single token by JTI.
§Errors
Returns RevocationError if the underlying revocation store operation fails.
Sourcepub async fn revoke_all_for_user(
&self,
sub: &str,
) -> Result<u64, RevocationError>
pub async fn revoke_all_for_user( &self, sub: &str, ) -> Result<u64, RevocationError>
Revoke all tokens for a user.
§Errors
Returns RevocationError if the underlying revocation store operation fails.
Sourcepub const fn require_jti(&self) -> bool
pub const fn require_jti(&self) -> bool
Whether JTI is required.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TokenRevocationManager
impl !RefUnwindSafe for TokenRevocationManager
impl Send for TokenRevocationManager
impl Sync for TokenRevocationManager
impl Unpin for TokenRevocationManager
impl UnsafeUnpin for TokenRevocationManager
impl !UnwindSafe for TokenRevocationManager
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more