@@ -14,12 +14,15 @@ export interface OAuthOidcConfig {
1414 */
1515 clientId ?: string
1616 /**
17- * URL to the OpenID Configuration endpoint. Used to fetch the endpoint URLs from.
17+ * OpenID configuration. If a string is passed, it is considered to be the full URL to the OpenID configuration endpoint
18+ * where all required endpoints are listed and fetched from automatically.
1819 *
19- * @default process.env.NUXT_OAUTH_OIDC_CONFIG_URL
20+ * Alternatively, an object can be set with the required endpoint URLs.
21+ *
22+ * @default process.env.NUXT_OAUTH_OIDC_OPENID_CONFIG
2023 * @example "https://my-provider.com/nidp/oauth/nam/.well-known/openid-configuration"
2124 */
22- configUrl ?: string
25+ openidConfig ?: string | OIDCConfiguration
2326 /**
2427 * OAuth Scope
2528 *
@@ -198,7 +201,7 @@ interface OidcUser {
198201/**
199202 * Address claim structure as defined in OpenID Connect specification
200203 */
201- export interface AddressClaim {
204+ interface AddressClaim {
202205 /** Full mailing address, formatted for display or use on a mailing label */
203206 formatted ?: string
204207 /** Full street address component, which may include house number, street name, post office box, and multi-line extended street address information */
@@ -219,6 +222,12 @@ interface OidcTokens {
219222 token_type : string
220223}
221224
225+ interface OIDCConfiguration {
226+ authorization_endpoint : string
227+ token_endpoint : string
228+ userinfo_endpoint ?: string
229+ }
230+
222231/**
223232 * Event handler for generic OAuth using OIDC and PKCE.
224233 */
@@ -241,11 +250,11 @@ export function defineOAuthOidcEventHandler<TUser = OidcUser>({ config, onSucces
241250 return onError ( event , error )
242251 }
243252
244- if ( ! config . clientId || ! config . configUrl ) {
245- return handleMissingConfiguration ( event , 'oidc' , [ 'clientId' , 'configUrl ' ] , onError )
253+ if ( ! config . clientId || ! config . openidConfig ) {
254+ return handleMissingConfiguration ( event , 'oidc' , [ 'clientId' , 'openidConfig ' ] , onError )
246255 }
247256
248- const oidcConfig = await $fetch < { authorization_endpoint : string , token_endpoint : string , userinfo_endpoint ?: string } > ( config . configUrl )
257+ const oidcConfig = typeof config . openidConfig === ' string' ? await $fetch < OIDCConfiguration > ( config . openidConfig ) : config . openidConfig
249258
250259 const redirectURL = config . redirectURL || getOAuthRedirectURL ( event )
251260 const state = await handleState ( event )
0 commit comments