pub struct AuthService { /* private fields */ }Expand description
认证领域服务 | Authentication domain service
Implementations§
Source§impl AuthService
impl AuthService
Sourcepub 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
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
构造服务。
Sourcepub fn token_repo(&self) -> &Arc<TokenRepo> ⓘ
pub fn token_repo(&self) -> &Arc<TokenRepo> ⓘ
Token 仓储 | Token repository
Sourcepub fn session_repo(&self) -> &Arc<SessionRepo> ⓘ
pub fn session_repo(&self) -> &Arc<SessionRepo> ⓘ
Session 仓储 | Session repository
Sourcepub async fn login(&self, req: LoginRequest) -> SaTokenResult<TokenValue>
pub async fn login(&self, req: LoginRequest) -> SaTokenResult<TokenValue>
登录主流程:阶段化写入 + 逆序补偿 + CAS 提交点。
Sourcepub async fn logout(
&self,
token: &TokenValue,
keep_token_session: bool,
) -> SaTokenResult<()>
pub async fn logout( &self, token: &TokenValue, keep_token_session: bool, ) -> SaTokenResult<()>
登出(LOGOUT 模式)| Logout
Sourcepub async fn kick_out_by_token(
&self,
token: &TokenValue,
keep_token_session: bool,
) -> SaTokenResult<()>
pub async fn kick_out_by_token( &self, token: &TokenValue, keep_token_session: bool, ) -> SaTokenResult<()>
踢下线(KICKOUT 模式,标记 -5)| Kick out, marker -5
Sourcepub async fn logout_replaced(&self, token: &TokenValue) -> SaTokenResult<()>
pub async fn logout_replaced(&self, token: &TokenValue) -> SaTokenResult<()>
顶下线(REPLACED 模式,标记 -4)| Replace, marker -4
Sourcepub async fn logout_by_login_id(
&self,
login_type: &str,
login_id: &str,
) -> SaTokenResult<()>
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 时递归。
Sourcepub async fn kick_out(
&self,
login_type: &str,
login_id: &str,
) -> SaTokenResult<()>
pub async fn kick_out( &self, login_type: &str, login_id: &str, ) -> SaTokenResult<()>
按账号踢下线全部 token(KICKOUT 模式)。
Sourcepub async fn get_token_info(
&self,
token: &TokenValue,
) -> SaTokenResult<TokenInfo>
pub async fn get_token_info( &self, token: &TokenValue, ) -> SaTokenResult<TokenInfo>
读取并校验 token(按策略自动续签)。
Sourcepub async fn is_valid(&self, token: &TokenValue) -> bool
pub async fn is_valid(&self, token: &TokenValue) -> bool
token 是否有效 | Whether the token is valid
Sourcepub async fn renew_timeout(
&self,
token: &TokenValue,
timeout_seconds: i64,
) -> SaTokenResult<()>
pub async fn renew_timeout( &self, token: &TokenValue, timeout_seconds: i64, ) -> SaTokenResult<()>
手动续期到指定秒数(修 B1-29:只写一次存储)。
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AuthService
impl !UnwindSafe for AuthService
impl Freeze for AuthService
impl Send for AuthService
impl Sync for AuthService
impl Unpin for AuthService
impl UnsafeUnpin for AuthService
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