Skip to content

Commit

Permalink
Return unautorized immediately if authenticator found but request sho…
Browse files Browse the repository at this point in the history
…uld not be granted
  • Loading branch information
catper committed Sep 16, 2020
1 parent abba8e6 commit 30450ae
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions proxy/request_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ func (d *RequestHandler) HandleRequest(r *http.Request, rl *rule.Rule) (session
// return nil
case helper.ErrUnauthorized.ErrorField:
d.r.Logger().Info(err)
return nil, err
default:
d.r.Logger().WithError(err).
WithFields(fields).
Expand All @@ -244,15 +245,11 @@ func (d *RequestHandler) HandleRequest(r *http.Request, rl *rule.Rule) (session

if !found {
err := errors.WithStack(helper.ErrUnauthorized)
// found will only be true if an authenticator was found AND authorisation was granted so check
// that this wasn't just a problem with the request
if err.Error() != helper.ErrUnauthorized.ErrorField {
d.r.Logger().WithError(err).
WithFields(fields).
WithField("granted", false).
WithField("reason_id", "authentication_handler_no_match").
Warn("No authentication handler was responsible for handling the authentication request")
}
d.r.Logger().WithError(err).
WithFields(fields).
WithField("granted", false).
WithField("reason_id", "authentication_handler_no_match").
Warn("No authentication handler was responsible for handling the authentication request")
return nil, err
}

Expand Down

0 comments on commit 30450ae

Please sign in to comment.