Skip to main content

JwtAuthenticator

Struct JwtAuthenticator 

Source
pub struct JwtAuthenticator { /* private fields */ }
Expand description

Authenticator that issues and verifies real HS256 JWTs.

Implementations§

Source§

impl JwtAuthenticator

Source

pub fn new( secret: impl Into<String>, issuer: impl Into<String>, expiration: u64, ) -> Self

Source

pub fn with_password_verifier(self, verifier: Arc<dyn PasswordVerifier>) -> Self

配置密码验证器(v0.2.1 新增,修复 Critical S-1)

配置后,authenticate 会调用 verifier.verify_password 验证密码并获取 user_id。 生产环境必须调用此方法,否则 authenticate 不验证密码(Critical S-1)。

Source

pub fn authenticate( &self, credentials: &Credentials, ) -> Result<Token, AuthError>

Source

pub fn verify_token(&self, token: &str) -> Result<User, AuthError>

Source

pub fn refresh_token(&self, refresh_token: &str) -> Result<Token, AuthError>

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
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.