Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce refreshing threshold for platform access token #830

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading