Skip to content

Commit

Permalink
fix: add missing code to LambdaProxyIntegrationEvent class
Browse files Browse the repository at this point in the history
  • Loading branch information
DorianMazur committed May 28, 2024
1 parent 04d4047 commit 8f710c6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/events/http/createJWTAuthScheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default function createJWTAuthScheme(jwtOptions) {
return h.authenticated({
credentials: {
claims,
// scopes, // this is being ignored by serverless-offline
scopes,
},
})
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions src/events/http/lambda-events/LambdaProxyIntegrationEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ export default class LambdaProxyIntegrationEvent {
if (token) {
try {
claims = decodeJwt(token)
if (claims.scope) {
scopes = claims.scope.split(" ")
if (claims.scp || claims.scope) {
scopes = claims.scp || claims.scope.split(" ")
// In AWS HTTP Api the scope property is removed from the decoded JWT
// I'm leaving this property because I'm not sure how all of the authorizers
// for AWS REST Api handle JWT.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ export default class LambdaProxyIntegrationEventV2 {
if (token) {
try {
claims = decodeJwt(token)
if (claims.scope) {
scopes = claims.scope.split(" ")
if (claims.scp || claims.scope) {
scopes = claims.scp || claims.scope.split(" ")
// In AWS HTTP Api the scope property is removed from the decoded JWT
// I'm leaving this property because I'm not sure how all of the authorizers
// for AWS REST Api handle JWT.
Expand Down
1 change: 1 addition & 0 deletions tests/integration/jwt-authorizer/jwt-authorizer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ describe("jwt authorizer tests", function desc() {
expected: {
requestContext: {
claims: oktaJWT,
scopes: ["email", "profile", "openid"],
},
status: "authorized",
},
Expand Down

0 comments on commit 8f710c6

Please sign in to comment.