diff --git a/auth/authutils.go b/auth/authutils.go index b07f26f8f..b18ff7915 100644 --- a/auth/authutils.go +++ b/auth/authutils.go @@ -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 diff --git a/auth/servicedetails.go b/auth/servicedetails.go index dc3b391aa..36a807fba 100644 --- a/auth/servicedetails.go +++ b/auth/servicedetails.go @@ -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 }