From 187add9b84f26a4ba2086e3444032cd2b2210a9e Mon Sep 17 00:00:00 2001 From: SongLiangChen <462039091@qq.com> Date: Wed, 10 Oct 2018 11:02:45 +0800 Subject: [PATCH] add sessionid prefix --- session/session.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/session/session.go b/session/session.go index cf647521..f33c48e7 100644 --- a/session/session.go +++ b/session/session.go @@ -96,6 +96,7 @@ type ManagerConfig struct { EnableSidInHTTPHeader bool `json:"EnableSidInHTTPHeader"` SessionNameInHTTPHeader string `json:"SessionNameInHTTPHeader"` EnableSidInURLQuery bool `json:"EnableSidInURLQuery"` + SessionIDPrefix string `json:"sessionIDPrefix"` } // Manager contains Provider and its configuration. @@ -331,7 +332,11 @@ func (manager *Manager) sessionID() (string, error) { if n != len(b) || err != nil { 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.