Skip to content

Commit

Permalink
Deassociate
Browse files Browse the repository at this point in the history
  • Loading branch information
mjcmtb committed Sep 17, 2024
1 parent 112f5ea commit 49e3237
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tokencache/cache_token_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (c *cachingTokenSource) Token(ctx context.Context) (*oidc.Token, error) {
}

var newToken *oidc.Token
if token != nil && token.Valid() && !c.WithinGracePeriod(token) {
if token != nil && token.Valid() && TokenWithinGracePeriod(token) {
return token, nil
} else if token != nil && token.RefreshToken != "" {
// we have an expired token, try and refresh if we can.
Expand Down Expand Up @@ -120,7 +120,7 @@ func (c *cachingTokenSource) Token(ctx context.Context) (*oidc.Token, error) {
return newToken, nil
}

func (c *cachingTokenSource) WithinGracePeriod(token *oidc.Token) bool {
func TokenWithinGracePeriod(token *oidc.Token) bool {
gracePeriodStart := token.Claims.Expiry.Time().Add(-TokenExpirationGracePeriod)
return gracePeriodStart.Before(time.Now()) && token.Valid()
}

0 comments on commit 49e3237

Please sign in to comment.