mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
allow login using Query.
This commit is contained in:
parent
b675e4cc82
commit
5699ad0bf9
@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (manager *SessionManagerCtx) Authenticate(r *http.Request) (types.Session, error) {
|
func (manager *SessionManagerCtx) Authenticate(r *http.Request) (types.Session, error) {
|
||||||
id, secret, ok := r.BasicAuth()
|
id, secret, ok := getAuthData(r)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("no authentication provided")
|
return nil, fmt.Errorf("no authentication provided")
|
||||||
}
|
}
|
||||||
@ -24,3 +24,19 @@ func (manager *SessionManagerCtx) Authenticate(r *http.Request) (types.Session,
|
|||||||
|
|
||||||
return session, nil
|
return session, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getAuthData(r *http.Request) (string, string, bool) {
|
||||||
|
id, secret, ok := r.BasicAuth()
|
||||||
|
if ok {
|
||||||
|
return id, secret, true
|
||||||
|
}
|
||||||
|
|
||||||
|
id = r.URL.Query().Get("id")
|
||||||
|
secret = r.URL.Query().Get("secret")
|
||||||
|
|
||||||
|
if id != "" && secret != "" {
|
||||||
|
return id, secret, true
|
||||||
|
}
|
||||||
|
|
||||||
|
return "", "", false
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user