Skip to content

Commit

Permalink
Merge pull request #12 from sevenwestmedia-labs/feature/EDIT-1320_exp…
Browse files Browse the repository at this point in the history
…and-oidc-scope

EDIT-1320: Expand OIDC scope
  • Loading branch information
kieran-lawrence authored Aug 17, 2024
2 parents 6306c9c + 8506f31 commit b890e33
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/wild-eyes-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@wanews/lambda-edge-openid-auth': patch
---

Update oidc request scope
29 changes: 17 additions & 12 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface RawIdp {
export interface RawConfig {
unauthenticatedPaths: string[]
idps: RawIdp[]
scope?: string
}

export interface Idp {
Expand All @@ -33,6 +34,7 @@ export interface Config {
publicUrl: string
domain: string
redirectUri: string
scope: string | undefined
postLogoutRedirectUri: string
}

Expand All @@ -54,19 +56,22 @@ export async function getConfig(
publicUrl,
domain: request.headers.host[0].value,
redirectUri: `${publicUrl}${callbackPath}`,
scope: rawConfig.scope,
postLogoutRedirectUri: `${publicUrl}${logoutCompletePath}`,
},
idps: await Promise.all(rawConfig.idps.map(
async ({ clientId, clientSecret, name, props }) => {
const { discoveryDoc, jwks } = await providerMetadata(props)
return {
discoveryDoc,
jwks,
name,
clientId,
clientSecret,
}
},
)),
idps: await Promise.all(
rawConfig.idps.map(
async ({ clientId, clientSecret, name, props }) => {
const { discoveryDoc, jwks } = await providerMetadata(props)
return {
discoveryDoc,
jwks,
name,
clientId,
clientSecret,
}
},
),
),
}
}
2 changes: 1 addition & 1 deletion src/lib/handlers/redirect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function redirect(
redirect_uri: config.redirectUri,
response_type: 'code',
response_mode: 'query',
scope: 'openid offline_access',
scope: config.scope || 'openid offline_access',
nonce: n[0],
state: queryDict.next || '/',
client_id: idpConfig.clientId,
Expand Down

0 comments on commit b890e33

Please sign in to comment.