pub struct LogoutAction<A: AuthAuditHook = TracingAuditHook> { /* private fields */ }Expand description
登出 Action:按用户水位线撤销该用户此前签发的全部 Token(写入 Redis)。
通过 revoke_by_subject 写入 sub 的最小有效签发时间水位线,早于该时刻签发的
Access 与 Refresh Token 一次性失效,因此无需另行传入 Refresh Token。
§所有权校验(AUTH-4)
当请求携带 Bearer Token(Authorization 头)时,本 Action 会校验该 Bearer Token
的 sub 与待撤销 Token(input.token)的 sub 一致。不一致时返回
BaseError::PermissionDenied,防止用户撤销他人的 Token。
若请求未携带 Bearer Token,则待撤销 Token 本身必须尚未撤销;失效凭据不能 再次推进用户水位线、撤销后续新会话。
Implementations§
Source§impl<A: AuthAuditHook> LogoutAction<A>
impl<A: AuthAuditHook> LogoutAction<A>
Sourcepub fn with_audit(audit: A) -> Self
pub fn with_audit(audit: A) -> Self
用自定义审计钩子创建 LogoutAction。
Trait Implementations§
Source§impl<A: Default + AuthAuditHook> Default for LogoutAction<A>
impl<A: Default + AuthAuditHook> Default for LogoutAction<A>
Source§impl<A: AuthAuditHook> TypedAction for LogoutAction<A>
impl<A: AuthAuditHook> TypedAction for LogoutAction<A>
Source§fn display_name(&self) -> &'static str
fn display_name(&self) -> &'static str
用户可见的显示名(默认返回 name)
Source§fn description(&self) -> &'static str
fn description(&self) -> &'static str
简介(默认返回空字符串)
Source§fn http_method(&self) -> HttpMethod
fn http_method(&self) -> HttpMethod
原子注册的 HTTP method;默认 POST。
Source§fn success_status(&self) -> u16
fn success_status(&self) -> u16
成功响应状态码。
Source§fn response_kind(&self) -> ActionResponseKind
fn response_kind(&self) -> ActionResponseKind
成功响应的静态类别;默认是普通 JSON。
Source§fn permission_mode(&self) -> PermissionMode
fn permission_mode(&self) -> PermissionMode
权限匹配模式(默认 All,即 AND 语义)
Source§fn permissions(&self) -> &'static [Permission]
fn permissions(&self) -> &'static [Permission]
所需权限列表(默认为空)
Source§fn input_schema(&self) -> &'static RootSchema
fn input_schema(&self) -> &'static RootSchema
入参 JSON Schema(OnceLock 生成)
Source§fn output_schema(&self) -> &'static RootSchema
fn output_schema(&self) -> &'static RootSchema
出参 JSON Schema
Source§fn meta_static(&self) -> &'static ActionMeta
fn meta_static(&self) -> &'static ActionMeta
静态元信息聚合体
Source§fn multipart_spec(&self) -> Option<MultipartSpec>
fn multipart_spec(&self) -> Option<MultipartSpec>
可选的受限 multipart 请求契约;默认只接受 JSON。
Source§impl<A: AuthAuditHook> TypedHandler for LogoutAction<A>
impl<A: AuthAuditHook> TypedHandler for LogoutAction<A>
Source§type Input = LogoutInput
type Input = LogoutInput
输入类型(请求体反序列化目标)
Source§type Output = MessageResponse
type Output = MessageResponse
输出类型(响应数据序列化源)
Source§fn handle<'life0, 'async_trait>(
&'life0 self,
ctx: ActionContext,
input: LogoutInput,
) -> Pin<Box<dyn Future<Output = Result<MessageResponse, BaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
ctx: ActionContext,
input: LogoutInput,
) -> Pin<Box<dyn Future<Output = Result<MessageResponse, BaseError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
业务执行
Source§fn decode_input(
&self,
ctx: &mut ActionContext,
) -> Result<Self::Input, BaseError>
fn decode_input( &self, ctx: &mut ActionContext, ) -> Result<Self::Input, BaseError>
从请求构造 Input。旧 TypedHandler 默认读取 body;原生 Action 由 ParamInput
按 body/query/path/header 的静态定义覆盖该行为。
Auto Trait Implementations§
impl<A> Forget for LogoutAction<A>
impl<A> Freeze for LogoutAction<A>where
A: Freeze,
impl<A> Move for LogoutAction<A>
impl<A> RefUnwindSafe for LogoutAction<A>where
A: RefUnwindSafe,
impl<A> Send for LogoutAction<A>
impl<A> Sync for LogoutAction<A>
impl<A> Unpin for LogoutAction<A>where
A: Unpin,
impl<A> UnsafeUnpin for LogoutAction<A>where
A: UnsafeUnpin,
impl<A> UnwindSafe for LogoutAction<A>where
A: UnwindSafe,
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
Source§impl<T> DynAction for Twhere
T: TypedAction,
impl<T> DynAction for Twhere
T: TypedAction,
Source§fn dispatch<'life0, 'async_trait>(
&'life0 self,
ctx: ActionContext,
) -> Pin<Box<dyn Future<Output = Result<ApiResponse, BaseError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
fn dispatch<'life0, 'async_trait>(
&'life0 self,
ctx: ActionContext,
) -> Pin<Box<dyn Future<Output = Result<ApiResponse, BaseError>> + Send + 'async_trait>>where
'life0: 'async_trait,
T: 'async_trait,
派发:从 ctx 中提取输入、执行业务逻辑、封装响应
Source§fn meta(&self) -> &'static ActionMeta
fn meta(&self) -> &'static ActionMeta
获取静态元信息
Source§fn input_type_id(&self) -> TypeId
fn input_type_id(&self) -> TypeId
返回强类型输入的 TypeId;手写擦除实现默认不支持内部强类型调用。
Source§fn output_type_id(&self) -> TypeId
fn output_type_id(&self) -> TypeId
返回强类型输出的 TypeId;手写擦除实现默认不支持内部强类型调用。
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