pub struct JwtValidator { /* private fields */ }Expand description
JWT 验证器
用于验证和解码 JWT token
Implementations§
Source§impl JwtValidator
impl JwtValidator
Sourcepub fn with_config(secret: &[u8], config: JwtValidatorConfig) -> Self
pub fn with_config(secret: &[u8], config: JwtValidatorConfig) -> Self
使用密钥和配置创建验证器
Sourcepub fn from_rsa_public_key(public_key_pem: &[u8]) -> Result<Self>
pub fn from_rsa_public_key(public_key_pem: &[u8]) -> Result<Self>
使用 RSA 公钥创建验证器
Sourcepub fn from_ec_public_key(public_key_pem: &[u8]) -> Result<Self>
pub fn from_ec_public_key(public_key_pem: &[u8]) -> Result<Self>
使用 EC 公钥创建验证器
Sourcepub fn set_config(&mut self, config: JwtValidatorConfig)
pub fn set_config(&mut self, config: JwtValidatorConfig)
设置配置
Sourcepub fn validate_with_claims<T: DeserializeOwned>(
&self,
token: &str,
) -> Result<T>
pub fn validate_with_claims<T: DeserializeOwned>( &self, token: &str, ) -> Result<T>
验证并解码 JWT,返回自定义 Claims 类型
Auto Trait Implementations§
impl Freeze for JwtValidator
impl RefUnwindSafe for JwtValidator
impl Send for JwtValidator
impl Sync for JwtValidator
impl Unpin for JwtValidator
impl UnwindSafe for JwtValidator
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