23d79b8b by astaxie

#254 add SessionHashFunc SessionHashKey SessionCookieLifeTime

1 parent 9ccdb310
...@@ -71,7 +71,14 @@ func Run() { ...@@ -71,7 +71,14 @@ func Run() {
71 } 71 }
72 72
73 if SessionOn { 73 if SessionOn {
74 GlobalSessions, _ = session.NewManager(SessionProvider, SessionName, SessionGCMaxLifetime, SessionSavePath, HttpTLS) 74 GlobalSessions, _ = session.NewManager(SessionProvider,
75 SessionName,
76 SessionGCMaxLifetime,
77 SessionSavePath,
78 HttpTLS,
79 SessionHashFunc,
80 SessionHashKey,
81 SessionCookieLifeTime)
75 go GlobalSessions.GC() 82 go GlobalSessions.GC()
76 } 83 }
77 84
......
...@@ -30,26 +30,29 @@ var ( ...@@ -30,26 +30,29 @@ var (
30 RunMode string //"dev" or "prod" 30 RunMode string //"dev" or "prod"
31 AppConfig config.ConfigContainer 31 AppConfig config.ConfigContainer
32 //related to session 32 //related to session
33 GlobalSessions *session.Manager //GlobalSessions 33 GlobalSessions *session.Manager //GlobalSessions
34 SessionOn bool // whether auto start session,default is false 34 SessionOn bool // whether auto start session,default is false
35 SessionProvider string // default session provider memory mysql redis 35 SessionProvider string // default session provider memory mysql redis
36 SessionName string // sessionName cookie's name 36 SessionName string // sessionName cookie's name
37 SessionGCMaxLifetime int64 // session's gc maxlifetime 37 SessionGCMaxLifetime int64 // session's gc maxlifetime
38 SessionSavePath string // session savepath if use mysql/redis/file this set to the connectinfo 38 SessionSavePath string // session savepath if use mysql/redis/file this set to the connectinfo
39 UseFcgi bool 39 SessionHashFunc string
40 MaxMemory int64 40 SessionHashKey string
41 EnableGzip bool // enable gzip 41 SessionCookieLifeTime int
42 DirectoryIndex bool //enable DirectoryIndex default is false 42 UseFcgi bool
43 EnableHotUpdate bool //enable HotUpdate default is false 43 MaxMemory int64
44 HttpServerTimeOut int64 //set httpserver timeout 44 EnableGzip bool // enable gzip
45 ErrorsShow bool //set weather show errors 45 DirectoryIndex bool //enable DirectoryIndex default is false
46 XSRFKEY string //set XSRF 46 EnableHotUpdate bool //enable HotUpdate default is false
47 EnableXSRF bool 47 HttpServerTimeOut int64 //set httpserver timeout
48 XSRFExpire int 48 ErrorsShow bool //set weather show errors
49 CopyRequestBody bool //When in raw application, You want to the reqeustbody 49 XSRFKEY string //set XSRF
50 TemplateLeft string 50 EnableXSRF bool
51 TemplateRight string 51 XSRFExpire int
52 BeegoServerName string 52 CopyRequestBody bool //When in raw application, You want to the reqeustbody
53 TemplateLeft string
54 TemplateRight string
55 BeegoServerName string
53 ) 56 )
54 57
55 func init() { 58 func init() {
...@@ -71,6 +74,9 @@ func init() { ...@@ -71,6 +74,9 @@ func init() {
71 SessionName = "beegosessionID" 74 SessionName = "beegosessionID"
72 SessionGCMaxLifetime = 3600 75 SessionGCMaxLifetime = 3600
73 SessionSavePath = "" 76 SessionSavePath = ""
77 SessionHashFunc = "sha1"
78 SessionHashKey = "beegoserversessionkey"
79 SessionCookieLifeTime = 3600
74 UseFcgi = false 80 UseFcgi = false
75 MaxMemory = 1 << 26 //64MB 81 MaxMemory = 1 << 26 //64MB
76 EnableGzip = false 82 EnableGzip = false
...@@ -157,6 +163,18 @@ func ParseConfig() (err error) { ...@@ -157,6 +163,18 @@ func ParseConfig() (err error) {
157 if sesssavepath := AppConfig.String("SessionSavePath"); sesssavepath != "" { 163 if sesssavepath := AppConfig.String("SessionSavePath"); sesssavepath != "" {
158 SessionSavePath = sesssavepath 164 SessionSavePath = sesssavepath
159 } 165 }
166 if sesshashfunc := AppConfig.String("sessionhashfunc"); sesshashfunc != "" {
167 SessionHashFunc = sesshashfunc
168 }
169 if sesshashfunc := AppConfig.String("SessionHashFunc"); sesshashfunc != "" {
170 SessionHashFunc = sesshashfunc
171 }
172 if sesshashkey := AppConfig.String("sessionhashkey"); sesshashkey != "" {
173 SessionHashKey = sesshashkey
174 }
175 if sesshashkey := AppConfig.String("SessionHashKey"); sesshashkey != "" {
176 SessionHashKey = sesshashkey
177 }
160 if sessMaxLifeTime, err := AppConfig.Int("sessiongcmaxlifetime"); err == nil && sessMaxLifeTime != 0 { 178 if sessMaxLifeTime, err := AppConfig.Int("sessiongcmaxlifetime"); err == nil && sessMaxLifeTime != 0 {
161 int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64) 179 int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
162 SessionGCMaxLifetime = int64val 180 SessionGCMaxLifetime = int64val
...@@ -165,6 +183,12 @@ func ParseConfig() (err error) { ...@@ -165,6 +183,12 @@ func ParseConfig() (err error) {
165 int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64) 183 int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
166 SessionGCMaxLifetime = int64val 184 SessionGCMaxLifetime = int64val
167 } 185 }
186 if sesscookielifetime, err := AppConfig.Int("sessioncookielifelime"); err == nil && sesscookielifetime != 0 {
187 SessionCookieLifeTime = sesscookielifetime
188 }
189 if sesscookielifetime, err := AppConfig.Int("SessionCookieLifeTime"); err == nil && sesscookielifetime != 0 {
190 SessionCookieLifeTime = sesscookielifetime
191 }
168 if usefcgi, err := AppConfig.Bool("usefcgi"); err == nil { 192 if usefcgi, err := AppConfig.Bool("usefcgi"); err == nil {
169 UseFcgi = usefcgi 193 UseFcgi = usefcgi
170 } 194 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!