mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-25 15:07:25 +02:00
allow login using Query.
This commit is contained in:
parent
b675e4cc82
commit
5699ad0bf9
1 changed files with 17 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue