Skip to content

Commit

Permalink
Simplify ClockSkew config
Browse files Browse the repository at this point in the history
  • Loading branch information
cgostuff committed Dec 14, 2021
1 parent 7764407 commit 5d6a6a7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions oidc/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ type Config struct {
// Time function to check Token expiry. Defaults to time.Now
Now func() time.Time

// Duration function for clock skew. Defaults to 5 minutes.
ClockSkew func() time.Duration
// Duration for clock skew. Defaults to 5 minutes.
ClockSkew time.Duration
}

// Verifier returns an IDTokenVerifier that uses the provider's key set to verify JWTs.
Expand Down Expand Up @@ -273,8 +273,8 @@ func (v *IDTokenVerifier) Verify(ctx context.Context, rawIDToken string) (*IDTok
// Set to 5 minutes by default since this is what other OpenID Connect providers do to deal with clock skew.
// https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/blob/6.12.2/src/Microsoft.IdentityModel.Tokens/TokenValidationParameters.cs#L149-L153
clockSkew := 5 * time.Minute
if v.config.ClockSkew != nil {
clockSkew = v.config.ClockSkew()
if v.config.ClockSkew > 0 {
clockSkew = v.config.ClockSkew
}

if t.Expiry.Before(nowTime.Add(-clockSkew)) {
Expand Down

0 comments on commit 5d6a6a7

Please sign in to comment.