mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
change authorization methods request priorities.
This commit is contained in:
parent
900ae006b8
commit
edfe9adde0
@ -27,12 +27,6 @@ func (manager *SessionManagerCtx) Authenticate(r *http.Request) (types.Session,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getToken(r *http.Request) (string, bool) {
|
func getToken(r *http.Request) (string, bool) {
|
||||||
// get from Cookie
|
|
||||||
cookie, err := r.Cookie("NEKO_SESSION")
|
|
||||||
if err == nil {
|
|
||||||
return cookie.Value, true
|
|
||||||
}
|
|
||||||
|
|
||||||
// get from Header
|
// get from Header
|
||||||
reqToken := r.Header.Get("Authorization")
|
reqToken := r.Header.Get("Authorization")
|
||||||
splitToken := strings.Split(reqToken, "Bearer ")
|
splitToken := strings.Split(reqToken, "Bearer ")
|
||||||
@ -40,6 +34,12 @@ func getToken(r *http.Request) (string, bool) {
|
|||||||
return strings.TrimSpace(splitToken[1]), true
|
return strings.TrimSpace(splitToken[1]), true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get from Cookie
|
||||||
|
cookie, err := r.Cookie("NEKO_SESSION")
|
||||||
|
if err == nil {
|
||||||
|
return cookie.Value, true
|
||||||
|
}
|
||||||
|
|
||||||
// get from URL
|
// get from URL
|
||||||
token := r.URL.Query().Get("token")
|
token := r.URL.Query().Get("token")
|
||||||
if token != "" {
|
if token != "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user