mirror of
https://github.com/nezhahq/nezha.git
synced 2025-03-12 00:38:13 -04:00
feat: add configurable JWT timeout setting (#1014)
This commit is contained in:
parent
5c8cc75523
commit
b23680f913
@ -22,8 +22,8 @@ func initParams() *jwt.GinJWTMiddleware {
|
|||||||
Key: []byte(singleton.Conf.JWTSecretKey),
|
Key: []byte(singleton.Conf.JWTSecretKey),
|
||||||
CookieName: "nz-jwt",
|
CookieName: "nz-jwt",
|
||||||
SendCookie: true,
|
SendCookie: true,
|
||||||
Timeout: time.Hour,
|
Timeout: time.Hour * time.Duration(singleton.Conf.JWTTimeout),
|
||||||
MaxRefresh: time.Hour,
|
MaxRefresh: time.Hour * time.Duration(singleton.Conf.JWTTimeout),
|
||||||
IdentityKey: model.CtxKeyAuthorizedUser,
|
IdentityKey: model.CtxKeyAuthorizedUser,
|
||||||
PayloadFunc: payloadFunc(),
|
PayloadFunc: payloadFunc(),
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ type ConfigDashboard struct {
|
|||||||
Location string `koanf:"location" json:"location,omitempty"` // 时区,默认为 Asia/Shanghai
|
Location string `koanf:"location" json:"location,omitempty"` // 时区,默认为 Asia/Shanghai
|
||||||
ForceAuth bool `koanf:"force_auth" json:"force_auth,omitempty"` // 强制要求认证
|
ForceAuth bool `koanf:"force_auth" json:"force_auth,omitempty"` // 强制要求认证
|
||||||
AgentSecretKey string `koanf:"agent_secret_key" json:"agent_secret_key,omitempty"`
|
AgentSecretKey string `koanf:"agent_secret_key" json:"agent_secret_key,omitempty"`
|
||||||
|
JWTTimeout int `mapstructure:"jwt_timeout" json:"jwt_timeout,omitempty"` // JWT token过期时间(小时)
|
||||||
|
|
||||||
EnablePlainIPInNotification bool `koanf:"enable_plain_ip_in_notification" json:"enable_plain_ip_in_notification,omitempty"` // 通知信息IP不打码
|
EnablePlainIPInNotification bool `koanf:"enable_plain_ip_in_notification" json:"enable_plain_ip_in_notification,omitempty"` // 通知信息IP不打码
|
||||||
|
|
||||||
@ -144,6 +145,11 @@ func (c *Config) Read(path string, frontendTemplates []FrontendTemplate) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add JWTTimeout default check
|
||||||
|
if c.JWTTimeout == 0 {
|
||||||
|
c.JWTTimeout = 1
|
||||||
|
}
|
||||||
|
|
||||||
if c.AgentSecretKey == "" {
|
if c.AgentSecretKey == "" {
|
||||||
c.AgentSecretKey, err = utils.GenerateRandomString(32)
|
c.AgentSecretKey, err = utils.GenerateRandomString(32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user