Skip to content

Commit

Permalink
Merge pull request #41 from TJM/feat/tokenid-errors
Browse files Browse the repository at this point in the history
feat: include tokenId in revoke errors
  • Loading branch information
alexhung authored Feb 27, 2023
2 parents a3ee54f + fe911f7 commit 222dd23
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions artifactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@ func (b *backend) revokeToken(config adminConfiguration, secret logical.Secret)
if newAccessReq {
resp, err = b.performArtifactoryDelete(config, "/access/api/v1/tokens/"+tokenId)
if err != nil {
b.Backend.Logger().Warn("error deleting access token", "response", resp, "err", err)
b.Backend.Logger().Warn("error deleting access token", "tokenId", tokenId, "response", resp, "err", err)
return err
}

} else {
resp, err = b.performArtifactoryPost(config, u.Path+"/api/security/token/revoke", values)
if err != nil {
b.Backend.Logger().Warn("error deleting token", "response", resp, "err", err)
b.Backend.Logger().Warn("error deleting token", "tokenId", tokenId, "response", resp, "err", err)
return err
}
}
//noinspection GoUnhandledErrorResult
defer resp.Body.Close()

if resp.StatusCode != http.StatusOK {
b.Backend.Logger().Warn("got non-200 status code", "statusCode", resp.StatusCode)
return fmt.Errorf("could not revoke token: HTTP response %v", resp.StatusCode)
if resp.StatusCode >= http.StatusBadRequest {
b.Backend.Logger().Warn("revokeToken got bad http status code", "statusCode", resp.StatusCode)
return fmt.Errorf("could not revoke tokenID: %v - HTTP response %v", tokenId, resp.StatusCode)
}

return nil
Expand Down

0 comments on commit 222dd23

Please sign in to comment.