allow login using Query.

This commit is contained in:
Miroslav Šedivý 2020-11-28 15:22:04 +01:00
parent b675e4cc82
commit 5699ad0bf9

View File

@ -8,7 +8,7 @@ import (
)
func (manager *SessionManagerCtx) Authenticate(r *http.Request) (types.Session, error) {
id, secret, ok := r.BasicAuth()
id, secret, ok := getAuthData(r)
if !ok {
return nil, fmt.Errorf("no authentication provided")
}
@ -24,3 +24,19 @@ func (manager *SessionManagerCtx) Authenticate(r *http.Request) (types.Session,
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
}