Fix collision between connect API key & Session middlewares
Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
@@ -49,12 +49,6 @@ func NewSessionMiddleware(svc *iam.Service, cookieConfig securecookie.Config) fu
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
apiKey := APIKeyFromContext(ctx)
|
||||
if apiKey != nil {
|
||||
httpserver.RenderError(w, http.StatusBadRequest, errors.New("session authentication cannot be used with API key authentication"))
|
||||
return
|
||||
}
|
||||
|
||||
cookieValue, err := securecookie.Get(r, cookieConfig)
|
||||
if err != nil {
|
||||
next.ServeHTTP(w, r)
|
||||
@@ -68,6 +62,12 @@ func NewSessionMiddleware(svc *iam.Service, cookieConfig securecookie.Config) fu
|
||||
return
|
||||
}
|
||||
|
||||
apiKey := APIKeyFromContext(ctx)
|
||||
if sessionID != gid.Nil && apiKey != nil {
|
||||
httpserver.RenderError(w, http.StatusBadRequest, errors.New("session authentication cannot be used with API key authentication"))
|
||||
return
|
||||
}
|
||||
|
||||
session, err := svc.SessionService.GetSession(ctx, sessionID)
|
||||
if err != nil {
|
||||
var errSessionNotFound *iam.ErrSessionNotFound
|
||||
|
||||
Reference in New Issue
Block a user