mirror of
https://github.com/astaxie/beego.git
synced 2024-11-26 12:11:28 +00:00
#254 add SessionHashFunc SessionHashKey SessionCookieLifeTime
This commit is contained in:
parent
9ccdb31003
commit
23d79b8b05
9
beego.go
9
beego.go
@ -71,7 +71,14 @@ func Run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if SessionOn {
|
if SessionOn {
|
||||||
GlobalSessions, _ = session.NewManager(SessionProvider, SessionName, SessionGCMaxLifetime, SessionSavePath, HttpTLS)
|
GlobalSessions, _ = session.NewManager(SessionProvider,
|
||||||
|
SessionName,
|
||||||
|
SessionGCMaxLifetime,
|
||||||
|
SessionSavePath,
|
||||||
|
HttpTLS,
|
||||||
|
SessionHashFunc,
|
||||||
|
SessionHashKey,
|
||||||
|
SessionCookieLifeTime)
|
||||||
go GlobalSessions.GC()
|
go GlobalSessions.GC()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
64
config.go
64
config.go
@ -30,26 +30,29 @@ var (
|
|||||||
RunMode string //"dev" or "prod"
|
RunMode string //"dev" or "prod"
|
||||||
AppConfig config.ConfigContainer
|
AppConfig config.ConfigContainer
|
||||||
//related to session
|
//related to session
|
||||||
GlobalSessions *session.Manager //GlobalSessions
|
GlobalSessions *session.Manager //GlobalSessions
|
||||||
SessionOn bool // whether auto start session,default is false
|
SessionOn bool // whether auto start session,default is false
|
||||||
SessionProvider string // default session provider memory mysql redis
|
SessionProvider string // default session provider memory mysql redis
|
||||||
SessionName string // sessionName cookie's name
|
SessionName string // sessionName cookie's name
|
||||||
SessionGCMaxLifetime int64 // session's gc maxlifetime
|
SessionGCMaxLifetime int64 // session's gc maxlifetime
|
||||||
SessionSavePath string // session savepath if use mysql/redis/file this set to the connectinfo
|
SessionSavePath string // session savepath if use mysql/redis/file this set to the connectinfo
|
||||||
UseFcgi bool
|
SessionHashFunc string
|
||||||
MaxMemory int64
|
SessionHashKey string
|
||||||
EnableGzip bool // enable gzip
|
SessionCookieLifeTime int
|
||||||
DirectoryIndex bool //enable DirectoryIndex default is false
|
UseFcgi bool
|
||||||
EnableHotUpdate bool //enable HotUpdate default is false
|
MaxMemory int64
|
||||||
HttpServerTimeOut int64 //set httpserver timeout
|
EnableGzip bool // enable gzip
|
||||||
ErrorsShow bool //set weather show errors
|
DirectoryIndex bool //enable DirectoryIndex default is false
|
||||||
XSRFKEY string //set XSRF
|
EnableHotUpdate bool //enable HotUpdate default is false
|
||||||
EnableXSRF bool
|
HttpServerTimeOut int64 //set httpserver timeout
|
||||||
XSRFExpire int
|
ErrorsShow bool //set weather show errors
|
||||||
CopyRequestBody bool //When in raw application, You want to the reqeustbody
|
XSRFKEY string //set XSRF
|
||||||
TemplateLeft string
|
EnableXSRF bool
|
||||||
TemplateRight string
|
XSRFExpire int
|
||||||
BeegoServerName string
|
CopyRequestBody bool //When in raw application, You want to the reqeustbody
|
||||||
|
TemplateLeft string
|
||||||
|
TemplateRight string
|
||||||
|
BeegoServerName string
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -71,6 +74,9 @@ func init() {
|
|||||||
SessionName = "beegosessionID"
|
SessionName = "beegosessionID"
|
||||||
SessionGCMaxLifetime = 3600
|
SessionGCMaxLifetime = 3600
|
||||||
SessionSavePath = ""
|
SessionSavePath = ""
|
||||||
|
SessionHashFunc = "sha1"
|
||||||
|
SessionHashKey = "beegoserversessionkey"
|
||||||
|
SessionCookieLifeTime = 3600
|
||||||
UseFcgi = false
|
UseFcgi = false
|
||||||
MaxMemory = 1 << 26 //64MB
|
MaxMemory = 1 << 26 //64MB
|
||||||
EnableGzip = false
|
EnableGzip = false
|
||||||
@ -157,6 +163,18 @@ func ParseConfig() (err error) {
|
|||||||
if sesssavepath := AppConfig.String("SessionSavePath"); sesssavepath != "" {
|
if sesssavepath := AppConfig.String("SessionSavePath"); sesssavepath != "" {
|
||||||
SessionSavePath = sesssavepath
|
SessionSavePath = sesssavepath
|
||||||
}
|
}
|
||||||
|
if sesshashfunc := AppConfig.String("sessionhashfunc"); sesshashfunc != "" {
|
||||||
|
SessionHashFunc = sesshashfunc
|
||||||
|
}
|
||||||
|
if sesshashfunc := AppConfig.String("SessionHashFunc"); sesshashfunc != "" {
|
||||||
|
SessionHashFunc = sesshashfunc
|
||||||
|
}
|
||||||
|
if sesshashkey := AppConfig.String("sessionhashkey"); sesshashkey != "" {
|
||||||
|
SessionHashKey = sesshashkey
|
||||||
|
}
|
||||||
|
if sesshashkey := AppConfig.String("SessionHashKey"); sesshashkey != "" {
|
||||||
|
SessionHashKey = sesshashkey
|
||||||
|
}
|
||||||
if sessMaxLifeTime, err := AppConfig.Int("sessiongcmaxlifetime"); err == nil && sessMaxLifeTime != 0 {
|
if sessMaxLifeTime, err := AppConfig.Int("sessiongcmaxlifetime"); err == nil && sessMaxLifeTime != 0 {
|
||||||
int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
|
int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
|
||||||
SessionGCMaxLifetime = int64val
|
SessionGCMaxLifetime = int64val
|
||||||
@ -165,6 +183,12 @@ func ParseConfig() (err error) {
|
|||||||
int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
|
int64val, _ := strconv.ParseInt(strconv.Itoa(sessMaxLifeTime), 10, 64)
|
||||||
SessionGCMaxLifetime = int64val
|
SessionGCMaxLifetime = int64val
|
||||||
}
|
}
|
||||||
|
if sesscookielifetime, err := AppConfig.Int("sessioncookielifelime"); err == nil && sesscookielifetime != 0 {
|
||||||
|
SessionCookieLifeTime = sesscookielifetime
|
||||||
|
}
|
||||||
|
if sesscookielifetime, err := AppConfig.Int("SessionCookieLifeTime"); err == nil && sesscookielifetime != 0 {
|
||||||
|
SessionCookieLifeTime = sesscookielifetime
|
||||||
|
}
|
||||||
if usefcgi, err := AppConfig.Bool("usefcgi"); err == nil {
|
if usefcgi, err := AppConfig.Bool("usefcgi"); err == nil {
|
||||||
UseFcgi = usefcgi
|
UseFcgi = usefcgi
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user