mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 21:01:31 +00:00
fix #1152
This commit is contained in:
parent
2dca48f26e
commit
9fd7acf663
@ -147,7 +147,7 @@ func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (se
|
||||
Value: url.QueryEscape(sid),
|
||||
Path: "/",
|
||||
HttpOnly: true,
|
||||
Secure: manager.config.Secure,
|
||||
Secure: manager.isSecure(r),
|
||||
Domain: manager.config.Domain}
|
||||
if manager.config.CookieLifeTime > 0 {
|
||||
cookie.MaxAge = manager.config.CookieLifeTime
|
||||
@ -174,7 +174,7 @@ func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (se
|
||||
Value: url.QueryEscape(sid),
|
||||
Path: "/",
|
||||
HttpOnly: true,
|
||||
Secure: manager.config.Secure,
|
||||
Secure: manager.isSecure(r),
|
||||
Domain: manager.config.Domain}
|
||||
if manager.config.CookieLifeTime > 0 {
|
||||
cookie.MaxAge = manager.config.CookieLifeTime
|
||||
@ -233,7 +233,7 @@ func (manager *Manager) SessionRegenerateId(w http.ResponseWriter, r *http.Reque
|
||||
Value: url.QueryEscape(sid),
|
||||
Path: "/",
|
||||
HttpOnly: true,
|
||||
Secure: manager.config.Secure,
|
||||
Secure: manager.isSecure(r),
|
||||
Domain: manager.config.Domain,
|
||||
}
|
||||
} else {
|
||||
@ -270,3 +270,17 @@ func (manager *Manager) sessionId(r *http.Request) (string, error) {
|
||||
}
|
||||
return hex.EncodeToString(b), nil
|
||||
}
|
||||
|
||||
// Set cookie with https.
|
||||
func (manager *Manager) isSecure(req *http.Request) bool {
|
||||
if !manager.config.Secure {
|
||||
return false
|
||||
}
|
||||
if req.URL.Scheme != "" {
|
||||
return req.URL.Scheme == "https"
|
||||
}
|
||||
if req.TLS == nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user