Documentation
¶
Index ¶
- type JWT
- func (j *JWT) Clone() internal.Configurable
- func (j *JWT) Get() interface{}
- func (j *JWT) Reload(data interface{})
- func (j *JWT) Set(data interface{})
- func (j *JWT) Validate() error
- func (j *JWT) WithAlgorithm(algorithm string) *JWT
- func (j *JWT) WithAudience(audience string) *JWT
- func (j *JWT) WithBufferTime(bufferTime int64) *JWT
- func (j *JWT) WithCustomClaims(customClaims map[string]interface{}) *JWT
- func (j *JWT) WithEnableRefresh(enableRefresh bool) *JWT
- func (j *JWT) WithExpiresTime(expiresTime int64) *JWT
- func (j *JWT) WithIssuer(issuer string) *JWT
- func (j *JWT) WithModuleName(moduleName string) *JWT
- func (j *JWT) WithRefreshTokenLife(refreshTokenLife int64) *JWT
- func (j *JWT) WithSigningKey(signingKey string) *JWT
- func (j *JWT) WithSubject(subject string) *JWT
- func (j *JWT) WithUseMultipoint(useMultipoint bool) *JWT
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JWT ¶
type JWT struct {
ModuleName string `mapstructure:"module-name" yaml:"module-name" json:"moduleName"` // 模块名称
SigningKey string `mapstructure:"signing-key" yaml:"signing-key" json:"signingKey" validate:"required"` // jwt 签名
ExpiresTime int64 `mapstructure:"expires-time" yaml:"expires-time" json:"expiresTime" validate:"required,min=1"` // 过期时间(单位:秒)
BufferTime int64 `mapstructure:"buffer-time" yaml:"buffer-time" json:"bufferTime" validate:"required,min=0"` // 缓冲时间(单位:秒)
UseMultipoint bool `mapstructure:"use-multipoint" yaml:"use-multipoint" json:"useMultipoint"` // 多地登录拦截,true 表示拦截,false 表示不拦截
Issuer string `mapstructure:"issuer" yaml:"issuer" json:"issuer"` // JWT 发行者
Audience string `mapstructure:"audience" yaml:"audience" json:"audience"` // JWT 接收者
Algorithm string `mapstructure:"algorithm" yaml:"algorithm" json:"algorithm" validate:"required"` // 签名算法,例如 HMAC, RSA, etc.
EnableRefresh bool `mapstructure:"enable-refresh" yaml:"enable-refresh" json:"enableRefresh"` // 是否启用刷新 token
RefreshTokenLife int64 `mapstructure:"refresh-token-life" yaml:"refresh-token-life" json:"refreshTokenLife" validate:"min=1"` // 刷新 token 生命周期(单位:秒)
Subject string `mapstructure:"subject" yaml:"subject" json:"subject"` // JWT 主题
CustomClaims map[string]interface{} `mapstructure:"custom-claims" yaml:"custom-claims" json:"customClaims"` // 自定义声明
}
JWT 结构体用于配置 JSON Web Token 的相关参数
func (*JWT) WithBufferTime ¶
WithBufferTime 设置缓冲时间(单位:秒)
func (*JWT) WithCustomClaims ¶
WithCustomClaims 设置自定义声明
func (*JWT) WithEnableRefresh ¶
WithEnableRefresh 设置是否启用刷新 token
func (*JWT) WithExpiresTime ¶
WithExpiresTime 设置过期时间(单位:秒)
func (*JWT) WithModuleName ¶
WithModuleName 设置模块名称
func (*JWT) WithRefreshTokenLife ¶
WithRefreshTokenLife 设置刷新 token 生命周期(单位:秒)
func (*JWT) WithSigningKey ¶
WithSigningKey 设置签名密钥
func (*JWT) WithUseMultipoint ¶
WithUseMultipoint 设置是否启用多地登录拦截
Click to show internal directories.
Click to hide internal directories.