#254 add SessionHashFunc SessionHashKey SessionCookieLifeTime
Showing
2 changed files
with
32 additions
and
1 deletions
| ... | @@ -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 | ... | ... |
| ... | @@ -36,6 +36,9 @@ var ( | ... | @@ -36,6 +36,9 @@ var ( |
| 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 | SessionHashFunc string | ||
| 40 | SessionHashKey string | ||
| 41 | SessionCookieLifeTime int | ||
| 39 | UseFcgi bool | 42 | UseFcgi bool |
| 40 | MaxMemory int64 | 43 | MaxMemory int64 |
| 41 | EnableGzip bool // enable gzip | 44 | EnableGzip bool // enable gzip |
| ... | @@ -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 | } | ... | ... |
-
Please register or sign in to post a comment