Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/jfrog/jfrog-client-go into s…
Browse files Browse the repository at this point in the history
…imple-json
  • Loading branch information
sverdlov93 committed Sep 13, 2023
2 parents 3cc9ccb + 14d189a commit 9c98a5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions auth/authutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,10 @@ type TokenPayload struct {
}

// Refreshable Tokens Constants.
// Artifactory's refresh token mechanism creates tokens that expire in 60 minutes. We want to refresh them when 10 minutes are left.
var RefreshArtifactoryTokenBeforeExpiryMinutes = int64(10)

// RefreshBeforeExpiryMinutes Artifactory's refresh token mechanism creates tokens that expired in 60 minutes. We want to refresh them after 50 minutes (when 10 minutes left)
var RefreshBeforeExpiryMinutes = int64(10)

// InviteRefreshBeforeExpiryMinutes Invitations mechanism creates tokens that are valid for 1 year. We want to refresh the token every 50 minutes.
var InviteRefreshBeforeExpiryMinutes = int64(365*24*60 - 50)
// Platform's access token are created with 1 year expiry. We want to refresh the token a week before expiry.
var RefreshPlatformTokenBeforeExpiryMinutes = int64(7 * 24 * 60)

const WaitBeforeRefreshSeconds = 15
2 changes: 1 addition & 1 deletion auth/servicedetails.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func SshTokenRefreshPreRequestInterceptor(fields *CommonConfigFields, httpClient
}
curToken := httpClientDetails.Headers["Authorization"]
timeLeft, err := GetTokenMinutesLeft(curToken)
if err != nil || timeLeft > RefreshBeforeExpiryMinutes {
if err != nil || timeLeft > RefreshArtifactoryTokenBeforeExpiryMinutes {
return err
}

Expand Down

0 comments on commit 9c98a5a

Please sign in to comment.