SaTokenConfig

Struct SaTokenConfig 

Source
pub struct SaTokenConfig {
Show 20 fields pub token_name: String, pub timeout: i64, pub active_timeout: i64, pub auto_renew: bool, pub is_concurrent: bool, pub is_share: bool, pub token_style: TokenStyle, pub is_log: bool, pub is_read_cookie: bool, pub is_read_header: bool, pub is_read_body: bool, pub token_prefix: Option<String>, pub jwt_secret_key: Option<String>, pub jwt_algorithm: Option<String>, pub jwt_issuer: Option<String>, pub jwt_audience: Option<String>, pub enable_nonce: bool, pub nonce_timeout: i64, pub enable_refresh_token: bool, pub refresh_token_timeout: i64,
}
Expand description

sa-token 配置

Fields§

§token_name: String

Token 名称(例如在 header 或 cookie 中的键名)

§timeout: i64

Token 有效期(秒),-1 表示永久有效

§active_timeout: i64

Token 最低活跃频率(秒),-1 表示不限制

配合 auto_renew 使用时,表示自动续签的时长

§auto_renew: bool

是否开启自动续签(默认 false)

如果设置为 true,在以下场景会自动续签 token:

  • 调用 get_token_info() 时
  • 中间件验证 token 时
  • 调用无参数的 StpUtil 方法时

续签时长由 active_timeout 决定:

  • 如果 active_timeout > 0,则续签 active_timeout 秒
  • 如果 active_timeout <= 0,则续签 timeout 秒
§is_concurrent: bool

是否允许同一账号并发登录

§is_share: bool

在多人登录同一账号时,是否共享一个 token

§token_style: TokenStyle

Token 风格(uuid、simple-uuid、random-32、random-64、random-128)

§is_log: bool

是否输出操作日志

§is_read_cookie: bool

是否从 cookie 中读取 token

§is_read_header: bool

是否从 header 中读取 token

§is_read_body: bool

是否从请求体中读取 token

§token_prefix: Option<String>

token 前缀(例如 “Bearer “)

§jwt_secret_key: Option<String>

JWT 密钥(如果使用 JWT)

§jwt_algorithm: Option<String>

JWT 算法(默认 HS256)

§jwt_issuer: Option<String>

JWT 签发者

§jwt_audience: Option<String>

JWT 受众

§enable_nonce: bool

是否启用防重放攻击(nonce 机制)

§nonce_timeout: i64

Nonce 有效期(秒),-1 表示使用 token timeout

§enable_refresh_token: bool

是否启用 Refresh Token

§refresh_token_timeout: i64

Refresh Token 有效期(秒),默认 7 天

Implementations§

Trait Implementations§

Source§

impl Clone for SaTokenConfig

Source§

fn clone(&self) -> SaTokenConfig

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SaTokenConfig

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for SaTokenConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for SaTokenConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SaTokenConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,