添加会话过期时间的环境变量配置;撤销令牌接口权限改为验证用户令牌

This commit is contained in:
2025-04-30 16:39:46 +08:00
parent fa356431ee
commit 1976baa164
4 changed files with 64 additions and 67 deletions

30
pkg/env/env.go vendored
View File

@@ -24,6 +24,35 @@ func loadApp() {
// endregion
// region auth
var (
SessionAccessExpire = 60 * 60 * 2 // 2小时
SessionRefreshExpire = 60 * 60 * 24 * 7 // 7天
)
func loadAuth() {
_SessionAccessExpire := os.Getenv("SESSION_ACCESS_EXPIRE")
if _SessionAccessExpire != "" {
value, err := strconv.Atoi(_SessionAccessExpire)
if err != nil {
panic("环境变量 SESSION_ACCESS_EXPIRE 的值不是数字")
}
SessionAccessExpire = value
}
_SessionRefreshExpire := os.Getenv("SESSION_REFRESH_EXPIRE")
if _SessionRefreshExpire != "" {
value, err := strconv.Atoi(_SessionRefreshExpire)
if err != nil {
panic("环境变量 SESSION_REFRESH_EXPIRE 的值不是数字")
}
SessionRefreshExpire = value
}
}
// endregion
// region db
var (
@@ -359,6 +388,7 @@ func Init() {
}
loadApp()
loadAuth()
loadDb()
loadRedis()
loadLog()