invalidate agent token on 403 as well (#1888)

This commit is contained in:
blotus 2022-11-25 14:35:50 +01:00 committed by GitHub
parent 2067ab0427
commit c5079ac15e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -194,7 +194,7 @@ func (t *JWTTransport) RoundTrip(req *http.Request) (*http.Response, error) {
dump, _ := httputil.DumpResponse(resp, true)
log.Tracef("resp-jwt: %s (err:%v)", string(dump), err)
}
if err != nil || resp.StatusCode == 401 {
if err != nil || resp.StatusCode == http.StatusForbidden || resp.StatusCode == http.StatusUnauthorized {
/*we had an error (network error for example, or 401 because token is refused), reset the token ?*/
t.token = ""
return resp, errors.Wrapf(err, "performing jwt auth")