Skip to content

Commit

Permalink
support a baseUrl for jwks_uri
Browse files Browse the repository at this point in the history
  • Loading branch information
mshick committed Mar 27, 2024
1 parent 3bef027 commit b6d9703
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/handlers/openid-configuration.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { HandlerOptions } from '../types.js'

function handler(options: HandlerOptions) {
const { issuer, origin } = options
const { issuer, origin, jwksUriBaseUrl } = options
return {
issuer,
jwks_uri: `${origin}/api/auth/all-access/jwks.json`,
// TODO Need to sniff this or at least make it configurable
jwks_uri: `${origin}/${jwksUriBaseUrl}/jwks.json`,
}
}

Expand Down
1 change: 1 addition & 0 deletions src/next-auth-all-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export function createInitializerOptions(options: NextAuthAllAccessOptions) {
issuer,
origin: getOrigin(options.origin),
jwks,
jwksUriBaseUrl: options.jwksUriBaseUrl ?? 'oidc',
}

const signingOptions: CreateSigningFnsParameters = {
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ export interface NextAuthAllAccessOptions {
privateKey?: string
issuer?: string
origin?: string
jwksUriBaseUrl?: string
}

export interface HandlerOptions {
jwks: JSONWebKeySet
jwksUriBaseUrl: string
issuer: string
origin: string
}
Expand Down

0 comments on commit b6d9703

Please # to comment.