SsoClient

Struct SsoClient 

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

SSO 客户端 | SSO Client

每个应用作为 SSO 客户端,处理本地会话和票据验证 Each application acts as SSO Client, handling local sessions and ticket validation

Implementations§

Source§

impl SsoClient

Source

pub fn new( manager: Arc<SaTokenManager>, server_url: String, service_url: String, ) -> Self

创建新的 SSO 客户端 | Create a new SSO Client

§参数 | Parameters
  • manager - SaTokenManager 实例 | SaTokenManager instance
  • server_url - SSO 服务端 URL | SSO Server URL
  • service_url - 当前服务 URL | Current service URL
Source

pub fn with_logout_callback<F>(self, callback: F) -> Self
where F: Fn(&str) -> bool + Send + Sync + 'static,

设置登出回调函数 | Set logout callback

§参数 | Parameters
  • callback - 登出时执行的回调函数 | Callback function to execute on logout
Source

pub fn get_login_url(&self) -> String

生成登录 URL | Generate login URL

§返回 | Returns

SSO 服务端登录 URL,包含当前服务的回调地址 SSO Server login URL with current service callback

Source

pub fn get_logout_url(&self) -> String

生成登出 URL | Generate logout URL

§返回 | Returns

SSO 服务端登出 URL,包含当前服务的回调地址 SSO Server logout URL with current service callback

Source

pub async fn check_local_login(&self, login_id: &str) -> bool

检查本地是否已登录 | Check if locally logged in

§参数 | Parameters
  • login_id - 用户登录 ID | User login ID
§返回 | Returns

是否已登录 | Whether logged in

Source

pub async fn process_ticket( &self, ticket: &str, service: &str, ) -> SaTokenResult<String>

处理票据(验证票据合法性)| Process ticket (validate ticket)

§参数 | Parameters
  • ticket - 票据 ID | Ticket ID
  • service - 服务 URL | Service URL
§返回 | Returns

处理后的票据信息 | Processed ticket info

§错误 | Errors
  • ServiceMismatch - 服务 URL 不匹配 | Service URL mismatch
Source

pub async fn login_by_ticket(&self, login_id: String) -> SaTokenResult<String>

通过票据登录(客户端本地登录)| Login by ticket (client-side local login)

§参数 | Parameters
  • login_id - 用户登录 ID | User login ID
§返回 | Returns

生成的本地 Token | Generated local token

Source

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

处理登出(客户端)| Handle logout (client-side)

§参数 | Parameters
  • login_id - 用户登录 ID | User login ID
Source

pub fn server_url(&self) -> &str

获取 SSO 服务端 URL | Get SSO Server URL

Source

pub fn service_url(&self) -> &str

获取当前服务 URL | Get current service URL

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

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
§

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

§

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> Same for T

Source§

type Output = T

Should always be Self
§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
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