pub struct AuthLayer {
pub jwt_secret: String,
pub ignore_paths: Vec<String>,
}Expand description
JWT 认证中间件
从 Authorization: Bearer <token> 中提取并验证 JWT,
将解析出的 UserContext 挂载到 request.extensions 中。
失败返回 401 Unauthorized。
Fields§
§jwt_secret: StringJWT 密钥(HS256)
ignore_paths: Vec<String>跳过认证的路径列表(如 /public/*、/api/login)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AuthLayer
impl RefUnwindSafe for AuthLayer
impl Send for AuthLayer
impl Sync for AuthLayer
impl Unpin for AuthLayer
impl UnsafeUnpin for AuthLayer
impl UnwindSafe for AuthLayer
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