Skip to content

Commit

Permalink
Add all status code to logs except 403 & 401
Browse files Browse the repository at this point in the history
Signed-off-by: Mustafa Abdelrahman <[email protected]>
  • Loading branch information
MustafaSaber committed Jul 17, 2023
1 parent af36abf commit 2038c62
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions filters/auth/authclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (ac *authClient) getTokenintrospect(token string, ctx filters.FilterContext

if rsp.StatusCode != 200 {
io.Copy(io.Discard, rsp.Body)
if rsp.StatusCode >= 500 && rsp.StatusCode <= 599 {
if rsp.StatusCode != 403 && rsp.StatusCode != 401 {
return nil, fmt.Errorf("token introspection failed with status code: %d", rsp.StatusCode)
}
return nil, errInvalidToken
Expand Down Expand Up @@ -130,7 +130,7 @@ func (ac *authClient) getTokeninfo(token string, ctx filters.FilterContext) (map

if rsp.StatusCode != 200 {
io.Copy(io.Discard, rsp.Body)
if rsp.StatusCode >= 500 && rsp.StatusCode <= 599 {
if rsp.StatusCode != 403 && rsp.StatusCode != 401 {
return nil, fmt.Errorf("token info failed with status code: %d", rsp.StatusCode)
}
return doc, errInvalidToken
Expand Down
5 changes: 1 addition & 4 deletions filters/auth/tokeninfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,7 @@ func TestOAuth2Tokeninfo5xx(t *testing.T) {
proxy := proxytest.New(fr, r)
defer proxy.Close()

reqURL, err := url.Parse(proxy.URL)
require.NoError(t, err, "Failed to parse url %s: %v", proxy.URL, err)

req, err := http.NewRequest("GET", reqURL.String(), nil)
req, err := http.NewRequest("GET", proxy.URL, nil)
require.NoError(t, err)

req.Header.Set(authHeaderName, authHeaderPrefix+testToken)
Expand Down

0 comments on commit 2038c62

Please sign in to comment.