File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
backend/domain/user/service Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import (
2525 "encoding/base64"
2626 "encoding/json"
2727 "fmt"
28+ "os"
2829 "strconv"
2930 "strings"
3031 "time"
@@ -575,8 +576,16 @@ type Session struct {
575576 ExpiresAt time.Time `json:"expires_at"` // 过期时间
576577}
577578
578- // 用于签名的密钥(在实际应用中应从配置中读取或使用环境变量)
579- var hmacSecret = []byte ("opencoze-session-hmac-key" )
579+ func initHmacSecret () []byte {
580+ SESSION_SECRET := os .Getenv ("SESSION_SECRET" )
581+ if len (SESSION_SECRET ) == 0 {
582+ SESSION_SECRET = "opencoze-session-hmac-key" // 默认的会话密钥
583+ }
584+ return []byte (SESSION_SECRET )
585+ }
586+
587+ // 用于签名的密钥
588+ var hmacSecret = initHmacSecret ()
580589
581590// 生成安全的会话密钥
582591func generateSessionKey (sessionID int64 ) (string , error ) {
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ export LOG_LEVEL="debug"
44export MAX_REQUEST_BODY_SIZE = 1073741824
55export SERVER_HOST = " localhost${ LISTEN_ADDR } "
66export MINIO_PROXY_ENDPOINT = " :8889"
7+ export SESSION_SECRET = " opencoze-session-hmac-key"
78
89# MySQL
910export MYSQL_ROOT_PASSWORD = root
You can’t perform that action at this time.
0 commit comments