Skip to content

Commit

Permalink
fix(oauth): allow 10 sec clock tolerance (#3071)
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsorban44 authored Oct 31, 2021
1 parent b66afcc commit 4181988
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/core/lib/oauth/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Issuer, Client } from "openid-client"
import { Issuer, Client, custom } from "openid-client"
import { InternalOptions } from "src/lib/types"

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

let issuer
let issuer: Issuer
if (provider.wellKnown) {
issuer = await Issuer.discover(provider.wellKnown)
} else {
Expand All @@ -31,13 +31,20 @@ export async function openidClient(

const client = new issuer.Client(
{
// @ts-expect-error
client_id: provider.clientId,
// @ts-expect-error
client_secret: provider.clientSecret,
redirect_uris: [provider.callbackUrl],
...provider.client,
},
provider.jwks
)

// allow a 10 second skew
// See https://github.com/nextauthjs/next-auth/issues/3032
// and https://github.com/nextauthjs/next-auth/issues/3067
client[custom.clock_tolerance] = 10

return client
}

0 comments on commit 4181988

Please sign in to comment.