Skip to content

Commit 5d6a6a7

Browse files
committed
Simplify ClockSkew config
1 parent 7764407 commit 5d6a6a7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

oidc/verify.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ type Config struct {
101101
// Time function to check Token expiry. Defaults to time.Now
102102
Now func() time.Time
103103

104-
// Duration function for clock skew. Defaults to 5 minutes.
105-
ClockSkew func() time.Duration
104+
// Duration for clock skew. Defaults to 5 minutes.
105+
ClockSkew time.Duration
106106
}
107107

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

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

0 commit comments

Comments
 (0)