pub struct SsoServer { /* private fields */ }Expand description
SSO 服务端 | SSO Server
中央认证服务,负责票据生成、验证和会话管理 Central authentication service responsible for ticket generation, validation, and session management
Implementations§
Source§impl SsoServer
impl SsoServer
Sourcepub fn new(manager: Arc<SaTokenManager>) -> SsoServer
pub fn new(manager: Arc<SaTokenManager>) -> SsoServer
创建新的 SSO 服务端 | Create a new SSO Server
§参数 | Parameters
manager- SaTokenManager 实例 | SaTokenManager instance
Sourcepub fn with_ticket_timeout(self, timeout: i64) -> SsoServer
pub fn with_ticket_timeout(self, timeout: i64) -> SsoServer
Sourcepub async fn is_logged_in(&self, login_id: &str) -> bool
pub async fn is_logged_in(&self, login_id: &str) -> bool
检查用户是否已登录 | Check if user is logged in
通过检查 SSO 会话是否存在来判断 Determined by checking if SSO session exists
Sourcepub async fn create_ticket(
&self,
login_id: String,
service: String,
) -> Result<SsoTicket, SaTokenError>
pub async fn create_ticket( &self, login_id: String, service: String, ) -> Result<SsoTicket, SaTokenError>
Sourcepub async fn validate_ticket(
&self,
ticket_id: &str,
service: &str,
) -> Result<String, SaTokenError>
pub async fn validate_ticket( &self, ticket_id: &str, service: &str, ) -> Result<String, SaTokenError>
验证票据 | Validate ticket
验证票据的有效性并将其标记为已使用(一次性使用) Validates ticket and marks it as used (one-time use)
§参数 | Parameters
ticket_id- 票据 ID | Ticket IDservice- 请求的服务 URL | Requested service URL
§返回 | Returns
用户登录 ID | User login ID
§错误 | Errors
InvalidTicket- 票据不存在 | Ticket not foundTicketExpired- 票据已过期或已使用 | Ticket expired or usedServiceMismatch- 服务 URL 不匹配 | Service URL mismatch
Sourcepub async fn login(
&self,
login_id: String,
service: String,
) -> Result<SsoTicket, SaTokenError>
pub async fn login( &self, login_id: String, service: String, ) -> Result<SsoTicket, SaTokenError>
pub async fn get_session(&self, login_id: &str) -> Option<SsoSession>
pub async fn check_session(&self, login_id: &str) -> bool
pub async fn cleanup_expired_tickets(&self)
pub async fn get_active_clients(&self, login_id: &str) -> Vec<String>
Auto Trait Implementations§
impl Freeze for SsoServer
impl !RefUnwindSafe for SsoServer
impl Send for SsoServer
impl Sync for SsoServer
impl Unpin for SsoServer
impl !UnwindSafe for SsoServer
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