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, ) -> Self
Sourcepub fn with_password_verifier(self, verifier: Arc<dyn PasswordVerifier>) -> Self
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)。
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