Skip to content

Commit d8a9188

Browse files
authored
feat(core): support private_key_jwt token auth method (#11132)
1 parent d38fdef commit d8a9188

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

packages/core/src/lib/actions/callback/oauth/callback.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ export async function handleOAuth(
105105
if (!options.isOnRedirectProxy && provider.redirectProxyUrl) {
106106
redirect_uri = provider.redirectProxyUrl
107107
}
108+
108109
let codeGrantResponse = await o.authorizationCodeGrantRequest(
109110
as,
110111
client,
@@ -121,6 +122,7 @@ export async function handleOAuth(
121122
}
122123
return fetch(...args)
123124
},
125+
clientPrivateKey: provider.token?.clientPrivateKey,
124126
}
125127
)
126128

packages/core/src/lib/utils/providers.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,12 @@ function normalizeEndpoint(
151151
url.searchParams.set(key, String(value))
152152
}
153153
}
154-
return { url, request: e?.request, conform: e?.conform }
154+
return {
155+
url,
156+
request: e?.request,
157+
conform: e?.conform,
158+
...(e?.clientPrivateKey ? { clientPrivateKey: e?.clientPrivateKey } : null),
159+
}
155160
}
156161

157162
export function isOIDCProvider(

packages/core/src/providers/oauth.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from "oauth4webapi"
1+
import type { Client, PrivateKey } from "oauth4webapi"
22
import type { CommonProviderOptions } from "../providers/index.js"
33
import type { Awaitable, Profile, TokenSet, User } from "../types.js"
44
import type { AuthConfig } from "../index.js"
@@ -45,6 +45,7 @@ interface AdvancedEndpointHandler<P extends UrlParams, C, R> {
4545
request?: EndpointRequest<C, R, P>
4646
/** @internal */
4747
conform?: (response: Response) => Awaitable<Response | undefined>
48+
clientPrivateKey?: CryptoKey | PrivateKey
4849
}
4950

5051
/**
@@ -263,6 +264,7 @@ export type OAuthConfigInternal<Profile> = Omit<
263264
token?: {
264265
url: URL
265266
request?: TokenEndpointHandler["request"]
267+
clientPrivateKey?: CryptoKey | PrivateKey
266268
/** @internal */
267269
conform?: TokenEndpointHandler["conform"]
268270
}

0 commit comments

Comments
 (0)