mirror of
https://github.com/astaxie/beego.git
synced 2024-12-23 01:10:51 +00:00
fix #1152
This commit is contained in:
parent
740a526105
commit
519602a553
@ -147,7 +147,7 @@ func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (se
|
|||||||
Value: url.QueryEscape(sid),
|
Value: url.QueryEscape(sid),
|
||||||
Path: "/",
|
Path: "/",
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Secure: manager.config.Secure,
|
Secure: manager.isSecure(r),
|
||||||
Domain: manager.config.Domain}
|
Domain: manager.config.Domain}
|
||||||
if manager.config.CookieLifeTime > 0 {
|
if manager.config.CookieLifeTime > 0 {
|
||||||
cookie.MaxAge = manager.config.CookieLifeTime
|
cookie.MaxAge = manager.config.CookieLifeTime
|
||||||
@ -174,7 +174,7 @@ func (manager *Manager) SessionStart(w http.ResponseWriter, r *http.Request) (se
|
|||||||
Value: url.QueryEscape(sid),
|
Value: url.QueryEscape(sid),
|
||||||
Path: "/",
|
Path: "/",
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Secure: manager.config.Secure,
|
Secure: manager.isSecure(r),
|
||||||
Domain: manager.config.Domain}
|
Domain: manager.config.Domain}
|
||||||
if manager.config.CookieLifeTime > 0 {
|
if manager.config.CookieLifeTime > 0 {
|
||||||
cookie.MaxAge = manager.config.CookieLifeTime
|
cookie.MaxAge = manager.config.CookieLifeTime
|
||||||
@ -233,7 +233,7 @@ func (manager *Manager) SessionRegenerateId(w http.ResponseWriter, r *http.Reque
|
|||||||
Value: url.QueryEscape(sid),
|
Value: url.QueryEscape(sid),
|
||||||
Path: "/",
|
Path: "/",
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Secure: manager.config.Secure,
|
Secure: manager.isSecure(r),
|
||||||
Domain: manager.config.Domain,
|
Domain: manager.config.Domain,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -270,3 +270,17 @@ func (manager *Manager) sessionId(r *http.Request) (string, error) {
|
|||||||
}
|
}
|
||||||
return hex.EncodeToString(b), nil
|
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