Skip to content

Commit 4181988

Browse files
fix(oauth): allow 10 sec clock tolerance (#3071)
1 parent b66afcc commit 4181988

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/core/lib/oauth/client.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Issuer, Client } from "openid-client"
1+
import { Issuer, Client, custom } from "openid-client"
22
import { InternalOptions } from "src/lib/types"
33

44
/**
@@ -13,7 +13,7 @@ export async function openidClient(
1313
): Promise<Client> {
1414
const provider = options.provider
1515

16-
let issuer
16+
let issuer: Issuer
1717
if (provider.wellKnown) {
1818
issuer = await Issuer.discover(provider.wellKnown)
1919
} else {
@@ -31,13 +31,20 @@ export async function openidClient(
3131

3232
const client = new issuer.Client(
3333
{
34+
// @ts-expect-error
3435
client_id: provider.clientId,
36+
// @ts-expect-error
3537
client_secret: provider.clientSecret,
3638
redirect_uris: [provider.callbackUrl],
3739
...provider.client,
3840
},
3941
provider.jwks
4042
)
4143

44+
// allow a 10 second skew
45+
// See https://github.com/nextauthjs/next-auth/issues/3032
46+
// and https://github.com/nextauthjs/next-auth/issues/3067
47+
client[custom.clock_tolerance] = 10
48+
4249
return client
4350
}

0 commit comments

Comments
 (0)