mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
read cookies only if enabled.
This commit is contained in:
parent
04d2fa8863
commit
4f1e3c879a
@ -55,6 +55,14 @@ func (manager *SessionManagerCtx) Authenticate(r *http.Request) (types.Session,
|
||||
}
|
||||
|
||||
func (manager *SessionManagerCtx) getToken(r *http.Request) (string, bool) {
|
||||
if manager.CookieEnabled() {
|
||||
// get from Cookie
|
||||
cookie, err := r.Cookie(manager.config.CookieName)
|
||||
if err == nil {
|
||||
return cookie.Value, true
|
||||
}
|
||||
}
|
||||
|
||||
// get from Header
|
||||
reqToken := r.Header.Get("Authorization")
|
||||
splitToken := strings.Split(reqToken, "Bearer ")
|
||||
@ -62,12 +70,6 @@ func (manager *SessionManagerCtx) getToken(r *http.Request) (string, bool) {
|
||||
return strings.TrimSpace(splitToken[1]), true
|
||||
}
|
||||
|
||||
// get from Cookie
|
||||
cookie, err := r.Cookie(manager.config.CookieName)
|
||||
if err == nil {
|
||||
return cookie.Value, true
|
||||
}
|
||||
|
||||
// get from URL
|
||||
token := r.URL.Query().Get("token")
|
||||
if token != "" {
|
||||
|
Loading…
Reference in New Issue
Block a user