Skip to content

Commit

Permalink
Merge branch 'master' into fix/deployment-resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
bashleigh authored Nov 15, 2024
2 parents 2ff5e32 + 56a0d99 commit cb451c6
Show file tree
Hide file tree
Showing 15 changed files with 7 additions and 4 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/fsevents-patch-19706e7e35-10.zip
Binary file not shown.
Binary file removed .yarn/cache/fsevents-patch-6b67494872-10.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/payments-service/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "payments-service",
"version": "3.0.0",
"version": "3.1.1",
"description": "Payments Proxy Service To API Platform",
"main": "index.js",
"repository": "[email protected]:reapit/foundations.git",
Expand Down
9 changes: 6 additions & 3 deletions packages/payments-service/src/core/authorizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ const customChallenge = async (event: APIGatewayTokenAuthorizerEvent, decodedTok

// I am repeating the checks I perform on the access token on the id token with the extra check of the reapit-customer
// against the clientId in the token
const issuer = idToken.payload.iss
const decodedIdToken = decode(idToken, { complete: true })

if (!decodedIdToken) throw new Error('Id Token failed to decode')
if (typeof decodedIdToken.payload === 'string') throw new Error('Decoded id token payload is a string')
if (!decodedIdToken.payload.sub) throw new Error('Id token does not contain a sub')

const issuer = decodedIdToken.payload.iss

// TODO We can remove this check when we go live with Auth0
// Check against cognito if token provided is valid
// else check auth0
Expand All @@ -52,7 +55,7 @@ const customChallenge = async (event: APIGatewayTokenAuthorizerEvent, decodedTok

// This is the crucial part of the check - I validate the idToken so I can trust it then check the reapit-customer
// header so my downstream services can trust it behind the gateway
if (reapitCustomer !== verified.clientId) {
if (reapitCustomer !== verified['custom:reapit:clientCode']) {
throw new Error('Reapit Customer does not match the decoded idToken')
}
}
Expand All @@ -73,7 +76,7 @@ const customChallenge = async (event: APIGatewayTokenAuthorizerEvent, decodedTok
if (!verified) throw new Error('Token failed to verify')
// This is the crucial part of the check - I validate the idToken so I can trust it then check the reapit-customer
// header so my downstream services can trust it behind the gateway
if (reapitCustomer !== verified.clientId) {
if (reapitCustomer !== verified['custom:reapit:clientCode']) {
throw new Error('Reapit Customer does not match the decoded idToken')
}
} else {
Expand Down

0 comments on commit cb451c6

Please sign in to comment.