pub struct JwtKeySet { /* private fields */ }Expand description
JWT 密钥集:支持多密钥并存,以 kid 标识,实现无停机密钥轮换
Implementations§
Source§impl JwtKeySet
impl JwtKeySet
Sourcepub fn new(
keys: HashMap<String, String>,
active_kid: String,
) -> Result<Self, AuthError>
pub fn new( keys: HashMap<String, String>, active_kid: String, ) -> Result<Self, AuthError>
创建密钥集,校验所有密钥长度 ≥ 32 字节,active_kid 存在于 keys
Sourcepub fn rotate(
&self,
new_kid: String,
new_secret: String,
) -> Result<(), AuthError>
pub fn rotate( &self, new_kid: String, new_secret: String, ) -> Result<(), AuthError>
轮换密钥:新增 kid 设为 active,保留旧 kid(旧令牌用旧密钥验证直至过期)
Sourcepub fn active_kid(&self) -> String
pub fn active_kid(&self) -> String
获取当前 active kid
Auto Trait Implementations§
impl !Freeze for JwtKeySet
impl RefUnwindSafe for JwtKeySet
impl Send for JwtKeySet
impl Sync for JwtKeySet
impl Unpin for JwtKeySet
impl UnsafeUnpin for JwtKeySet
impl UnwindSafe for JwtKeySet
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