Skip to main content

AuthService

Struct AuthService 

Source
pub struct AuthService { /* private fields */ }
Expand description

认证领域服务 | Authentication domain service

Implementations§

Source§

impl AuthService

Source

pub fn new( dao: Arc<SaTokenDao>, config: Arc<SaTokenConfig>, token_repo: Arc<TokenRepo>, session_repo: Arc<SessionRepo>, event_bus: SaTokenEventBus, online_manager: Option<Arc<OnlineManager>>, distributed: Option<Arc<DistributedSessionManager>>, ) -> Self

构造服务。

Source

pub fn token_repo(&self) -> &Arc<TokenRepo> ⓘ

Token 仓储 | Token repository

Source

pub fn session_repo(&self) -> &Arc<SessionRepo> ⓘ

Session 仓储 | Session repository

Source

pub async fn login(&self, req: LoginRequest) -> SaTokenResult<TokenValue>

登录主流程:阶段化写入 + 逆序补偿 + CAS 提交点。

Source

pub async fn logout( &self, token: &TokenValue, keep_token_session: bool, ) -> SaTokenResult<()>

登出(LOGOUT 模式)| Logout

Source

pub async fn kick_out_by_token( &self, token: &TokenValue, keep_token_session: bool, ) -> SaTokenResult<()>

踢下线(KICKOUT 模式,标记 -5)| Kick out, marker -5

Source

pub async fn logout_replaced(&self, token: &TokenValue) -> SaTokenResult<()>

顶下线(REPLACED 模式,标记 -4)| Replace, marker -4

Source

pub async fn logout_by_login_id( &self, login_type: &str, login_id: &str, ) -> SaTokenResult<()>

按账号登出全部 token(LOGOUT 模式)。

Always uses per-token [logout_internal] so logout_range=Account cannot recurse. 始终按单 token 调用 [logout_internal],避免 logout_range=Account 时递归。

Source

pub async fn kick_out( &self, login_type: &str, login_id: &str, ) -> SaTokenResult<()>

按账号踢下线全部 token(KICKOUT 模式)。

Source

pub async fn get_token_info( &self, token: &TokenValue, ) -> SaTokenResult<TokenInfo>

读取并校验 token(按策略自动续签)。

Source

pub async fn is_valid(&self, token: &TokenValue) -> bool

token 是否有效 | Whether the token is valid

Source

pub async fn renew_timeout( &self, token: &TokenValue, timeout_seconds: i64, ) -> SaTokenResult<()>

手动续期到指定秒数(修 B1-29:只写一次存储)。

Trait Implementations§

Source§

impl Debug for AuthService

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ForyObject for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more