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: StringToken 名称(例如在 header 或 cookie 中的键名)
timeout: i64Token 有效期(秒),-1 表示永久有效
active_timeout: i64Token 最低活跃频率(秒),-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是否允许同一账号并发登录
在多人登录同一账号时,是否共享一个 token
token_style: TokenStyleToken 风格(uuid、simple-uuid、random-32、random-64、random-128)
is_log: 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: i64Nonce 有效期(秒),-1 表示使用 token timeout
enable_refresh_token: bool是否启用 Refresh Token
refresh_token_timeout: i64Refresh Token 有效期(秒),默认 7 天
Implementations§
Source§impl SaTokenConfig
impl SaTokenConfig
pub fn builder() -> SaTokenConfigBuilder
pub fn timeout_duration(&self) -> Option<Duration>
Trait Implementations§
Source§impl Clone for SaTokenConfig
impl Clone for SaTokenConfig
Source§fn clone(&self) -> SaTokenConfig
fn clone(&self) -> SaTokenConfig
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SaTokenConfig
impl Debug for SaTokenConfig
Source§impl Default for SaTokenConfig
impl Default for SaTokenConfig
Source§fn default() -> SaTokenConfig
fn default() -> SaTokenConfig
Source§impl<'de> Deserialize<'de> for SaTokenConfig
impl<'de> Deserialize<'de> for SaTokenConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SaTokenConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SaTokenConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for SaTokenConfig
impl Serialize for SaTokenConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for SaTokenConfig
impl RefUnwindSafe for SaTokenConfig
impl Send for SaTokenConfig
impl Sync for SaTokenConfig
impl Unpin for SaTokenConfig
impl UnwindSafe for SaTokenConfig
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);