1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 07:10:55 +00:00

add sessionid prefix

This commit is contained in:
SongLiangChen 2018-10-10 11:02:45 +08:00
parent 7e0649d661
commit 187add9b84

View File

@ -96,6 +96,7 @@ type ManagerConfig struct {
EnableSidInHTTPHeader bool `json:"EnableSidInHTTPHeader"` EnableSidInHTTPHeader bool `json:"EnableSidInHTTPHeader"`
SessionNameInHTTPHeader string `json:"SessionNameInHTTPHeader"` SessionNameInHTTPHeader string `json:"SessionNameInHTTPHeader"`
EnableSidInURLQuery bool `json:"EnableSidInURLQuery"` EnableSidInURLQuery bool `json:"EnableSidInURLQuery"`
SessionIDPrefix string `json:"sessionIDPrefix"`
} }
// Manager contains Provider and its configuration. // Manager contains Provider and its configuration.
@ -331,7 +332,11 @@ func (manager *Manager) sessionID() (string, error) {
if n != len(b) || err != nil { if n != len(b) || err != nil {
return "", fmt.Errorf("Could not successfully read from the system CSPRNG") return "", fmt.Errorf("Could not successfully read from the system CSPRNG")
} }
return hex.EncodeToString(b), nil sid := hex.EncodeToString(b)
if manager.config.SessionIDPrefix != "" {
sid = manager.config.SessionIDPrefix + sid
}
return sid, nil
} }
// Set cookie with https. // Set cookie with https.