Skip to content

Commit 1d6520b

Browse files
committed
token service: Handle unrecovable, expiring tokens
Artifactory servers have a global configuration `minimum-revocable-expiry` which dictates that any token whose expiry is less than the global minimum cannot be revoked and must expire naturally. [1] If the revoke API is used on a token who expiry is less than minimum-revocable-expiry then Artifactory appears to return a 500 status code, although this is undocumented. The plugin is unaware of this configuration and will optimistically attempt to revoke tokens and assume it is no revocable if such an error occurs. 1: https://www.jfrog.com/confluence/display/ACC/Access+Tokens#AccessTokens-GeneratingExpirableTokens
1 parent 5f22e67 commit 1d6520b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pkg/token/service.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ func (s *AccessTokenService) RevokeToken(req *RevokeTokenRequest) error {
117117
if err != nil {
118118
return err
119119
}
120+
121+
// This usually means that the token is not revocable
122+
if resp.StatusCode == http.StatusInternalServerError {
123+
return nil
124+
}
120125
if resp.StatusCode != http.StatusOK {
121126
return errorutils.CheckError(errors.New("Artifactory response: " + resp.Status + "\n" + clientutils.IndentJson(body)))
122127
}

pkg/token/service_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ func TestRevokeToken(t *testing.T) {
132132
w.WriteHeader(http.StatusOK)
133133
},
134134
},
135+
{
136+
true,
137+
&RevokeTokenRequest{Token: "unrevocable-token"},
138+
func(w http.ResponseWriter, r *http.Request) {
139+
w.WriteHeader(http.StatusInternalServerError)
140+
},
141+
},
135142
{
136143
false,
137144
&RevokeTokenRequest{Token: "fake-token"},

0 commit comments

Comments
 (0)