satellite/console: bug fix for using a API key to retrieve a session
Change-Id: I0202f75fb78f42af9e7cb00bb3ac73839340c977
This commit is contained in:
parent
75d10fe4fa
commit
f87772a0d3
@ -132,14 +132,13 @@ func (a *Auth) TokenByAPIKey(w http.ResponseWriter, r *http.Request) {
|
|||||||
defer mon.Task()(&ctx)(&err)
|
defer mon.Task()(&ctx)(&err)
|
||||||
|
|
||||||
authToken := r.Header.Get("Authorization")
|
authToken := r.Header.Get("Authorization")
|
||||||
split := strings.Split(authToken, "Bearer ")
|
if !(strings.HasPrefix(authToken, "Bearer ")) {
|
||||||
if len(split) != 2 {
|
|
||||||
a.log.Info("authorization key format is incorrect. Should be 'Bearer <key>'")
|
a.log.Info("authorization key format is incorrect. Should be 'Bearer <key>'")
|
||||||
a.serveJSONError(w, err)
|
a.serveJSONError(w, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
apiKey := split[1]
|
apiKey := strings.TrimPrefix(authToken, "Bearer ")
|
||||||
|
|
||||||
userAgent := r.UserAgent()
|
userAgent := r.UserAgent()
|
||||||
ip, err := web.GetRequestIP(r)
|
ip, err := web.GetRequestIP(r)
|
||||||
|
Loading…
Reference in New Issue
Block a user