pub struct SsoServer { /* private fields */ }Expand description
SSO server: tickets, sessions, SLO. SSO 服务端:票据、会话、统一登出。
Implementations§
Source§impl SsoServer
impl SsoServer
Sourcepub fn new(manager: Arc<SaTokenManager>) -> Self
pub fn new(manager: Arc<SaTokenManager>) -> Self
Create a server from a manager (strict origin defaults). 从 manager 创建服务端(严格的 Origin 默认值)。
Sourcepub fn with_config(self, config: &SsoConfig) -> Self
pub fn with_config(self, config: &SsoConfig) -> Self
Apply SSO config (timeout, origins, sign). 应用 SSO 配置(超时、白名单、签名)。
Sourcepub fn with_ticket_timeout(self, timeout: i64) -> Self
pub fn with_ticket_timeout(self, timeout: i64) -> Self
Override ticket timeout seconds. 覆盖票据超时秒数。
Sourcepub fn with_slo_notifier(self, notifier: Arc<dyn SloNotifier>) -> Self
pub fn with_slo_notifier(self, notifier: Arc<dyn SloNotifier>) -> Self
Replace the SLO notifier (default NoopSloNotifier).
替换 SLO 通知器(默认 NoopSloNotifier)。
Sourcepub fn sign(&self) -> &RequestSign
pub fn sign(&self) -> &RequestSign
Shared request signer. 共享请求签名器。
Sourcepub fn is_allowed_origin(&self, origin: &str) -> bool
pub fn is_allowed_origin(&self, origin: &str) -> bool
Exact-match origin check (requires allow_cross_domain). 精确匹配 Origin 校验(需开启 allow_cross_domain)。
Sourcepub async fn create_ticket(
&self,
login_id: String,
service: String,
) -> SaTokenResult<SsoTicket>
pub async fn create_ticket( &self, login_id: String, service: String, ) -> SaTokenResult<SsoTicket>
Create and persist a ticket; upsert session client. 创建并持久化票据;upsert 会话客户端。
Sourcepub async fn validate_ticket(
&self,
ticket_id: &str,
service: &str,
) -> SaTokenResult<String>
pub async fn validate_ticket( &self, ticket_id: &str, service: &str, ) -> SaTokenResult<String>
Consume a ticket and return login_id. 消费票据并返回 login_id。
Sourcepub async fn check_ticket(
&self,
ticket_id: &str,
service: &str,
) -> SaTokenResult<CheckTicketResult>
pub async fn check_ticket( &self, ticket_id: &str, service: &str, ) -> SaTokenResult<CheckTicketResult>
Non-consuming ticket check. 非消费票据校验。
Sourcepub fn build_slo_logout_urls(client_urls: &[String]) -> Vec<String>
pub fn build_slo_logout_urls(client_urls: &[String]) -> Vec<String>
Build per-client SLO callback URLs. 构造各客户端 SLO 回调 URL。
Sourcepub async fn logout_with_slo(
&self,
login_id: &str,
) -> SaTokenResult<Vec<String>>
pub async fn logout_with_slo( &self, login_id: &str, ) -> SaTokenResult<Vec<String>>
Local logout then notify clients (failures are logged, not rolled back). 先本地登出再通知客户端(失败仅日志,不回滚)。
Sourcepub async fn login(
&self,
login_id: String,
service: String,
) -> SaTokenResult<SsoTicket>
pub async fn login( &self, login_id: String, service: String, ) -> SaTokenResult<SsoTicket>
Login at SSO server and issue a ticket for service.
在 SSO 服务端登录并为 service 签发票据。
Sourcepub async fn logout(&self, login_id: &str) -> SaTokenResult<Vec<String>>
pub async fn logout(&self, login_id: &str) -> SaTokenResult<Vec<String>>
Remove SSO session and logout related login types. 删除 SSO 会话并登出相关 login_type。
Sourcepub async fn get_session(&self, login_id: &str) -> Option<SsoSession>
pub async fn get_session(&self, login_id: &str) -> Option<SsoSession>
Load session if present. 若存在则加载会话。
Sourcepub async fn check_session(&self, login_id: &str) -> bool
pub async fn check_session(&self, login_id: &str) -> bool
True when a session exists. 存在会话时为 true。
Sourcepub async fn cleanup_expired_tickets(&self)
pub async fn cleanup_expired_tickets(&self)
No-op: ticket TTL is enforced by storage. 空操作:票据 TTL 由存储过期保证。
Sourcepub async fn get_active_clients(&self, login_id: &str) -> Vec<String>
pub async fn get_active_clients(&self, login_id: &str) -> Vec<String>
Active client URLs for login_id. login_id 的活跃客户端 URL。
Sourcepub async fn is_logged_in(&self, login_id: &str) -> bool
pub async fn is_logged_in(&self, login_id: &str) -> bool
Session present and SSO login_type still has tokens. 会话存在且 SSO login_type 仍有 token。