pub struct JwtAuthenticator { /* private fields */ }Expand description
Authenticator that issues and verifies real HS256 JWTs.
Implementations§
Source§impl JwtAuthenticator
impl JwtAuthenticator
pub fn new( secret: impl Into<String>, issuer: impl Into<String>, expiration: u64, ) -> JwtAuthenticator
Sourcepub fn with_password_verifier(
self,
verifier: Arc<dyn PasswordVerifier>,
) -> JwtAuthenticator
pub fn with_password_verifier( self, verifier: Arc<dyn PasswordVerifier>, ) -> JwtAuthenticator
配置密码验证器(v0.2.1 新增,修复 Critical S-1)
配置后,authenticate 会调用 verifier.verify_password 验证密码并获取 user_id。
生产环境必须调用此方法,否则 authenticate 不验证密码(Critical S-1)。
pub fn authenticate( &self, credentials: &Credentials, ) -> Result<Token, AuthError>
pub fn verify_token(&self, token: &str) -> Result<User, AuthError>
pub fn refresh_token(&self, refresh_token: &str) -> Result<Token, AuthError>
Auto Trait Implementations§
impl !RefUnwindSafe for JwtAuthenticator
impl !UnwindSafe for JwtAuthenticator
impl Freeze for JwtAuthenticator
impl Send for JwtAuthenticator
impl Sync for JwtAuthenticator
impl Unpin for JwtAuthenticator
impl UnsafeUnpin for JwtAuthenticator
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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