Skip to content

Commit

Permalink
fix: should be looked from the federation_fetch_endpoint instead of t…
Browse files Browse the repository at this point in the history
…he source_endpoint

Signed-off-by: Tom Lanser <[email protected]>
  • Loading branch information
Tommylans committed Nov 25, 2024
1 parent f3398c4 commit b736e9f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
6 changes: 5 additions & 1 deletion packages/core/__tests__/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ describe('End To End', async () => {
jwks: {
keys: [publicKeyJwk],
},
source_endpoint: `${iss}/fetch`,
metadata: {
federation_entity: {
federation_fetch_endpoint: `${iss}/fetch`,
},
},
},
header: {
kid: 'some-id',
Expand Down
30 changes: 25 additions & 5 deletions packages/core/__tests__/fetchEntityStatement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ describe('fetch entity statement', () => {
},
sub: iss,
iss,
source_endpoint: `${iss}/fetch`,
metadata: {
federation_entity: {
federation_fetch_endpoint: `${iss}/fetch`,
},
},
iat: 1,
exp: 1,
},
Expand Down Expand Up @@ -90,7 +94,11 @@ describe('fetch entity statement', () => {
},
sub: iss,
iss,
source_endpoint: `${iss}/fetch`,
metadata: {
federation_entity: {
federation_fetch_endpoint: `${iss}/fetch`,
},
},
iat: 1,
exp: 1,
},
Expand Down Expand Up @@ -152,7 +160,11 @@ describe('fetch entity statement', () => {
},
sub: iss,
iss,
source_endpoint: `${iss}/fetch`,
metadata: {
federation_entity: {
federation_fetch_endpoint: `${iss}/fetch`,
},
},
iat: 1,
exp: 1,
},
Expand Down Expand Up @@ -255,7 +267,11 @@ describe('fetch entity statement', () => {
iss,
iat: 1,
exp: 1,
source_endpoint: `${iss}/fetch`,
metadata: {
federation_entity: {
federation_fetch_endpoint: `${iss}/fetch`,
},
},
},
header: {
kid: 'a',
Expand Down Expand Up @@ -295,7 +311,11 @@ describe('fetch entity statement', () => {
},
sub: iss,
iss,
source_endpoint: `${iss}/fetch`,
metadata: {
federation_entity: {
federation_fetch_endpoint: `${iss}/fetch`,
},
},
iat: 1,
exp: 1,
},
Expand Down
6 changes: 5 additions & 1 deletion packages/core/__tests__/utils/setupConfigurationChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export const setupConfigurationChain = async (
iat: new Date(),
jwks: jwks ?? { keys: [{ kid: 'a', kty: 'EC' }] },
authority_hints: authorityHints,
source_endpoint: `${entityId}/fetch`,
metadata: {
federation_entity: {
federation_fetch_endpoint: `${entityId}/fetch`,
},
},
}

// fix so `undefined` is not in the expected claims
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/entityStatement/fetchEntityStatement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const fetchEntityStatement = async ({
const issEntityConfigurationClaims =
issEntityConfiguration ?? (await fetchEntityConfiguration({ entityId: iss, verifyJwtCallback }))

const fetchEndpoint = endpoint ?? issEntityConfigurationClaims.source_endpoint
const fetchEndpoint = endpoint ?? issEntityConfigurationClaims.metadata?.federation_entity?.federation_fetch_endpoint

if (!fetchEndpoint) {
throw new Error('No fetch endpoint provided or in the issuer configuration')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ export const fetchEntityStatementChain = async ({
// If we have no subject configuration we have reached the leaf entity as the `configuration`
if (!subjectConfiguration) continue

const fetchEndpoint = configuration?.source_endpoint
const fetchEndpoint = configuration?.metadata?.federation_entity?.federation_fetch_endpoint

if (!fetchEndpoint) {
throw new OpenIdFederationError(
ErrorCode.Validation,
`No source endpoint found for configuration for: '${configuration?.sub}'`
`No fetch endpoint found for configuration for: '${configuration?.sub}'`
)
}

Expand Down

0 comments on commit b736e9f

Please sign in to comment.