-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move events to api gateway v2 (#38)
- add headers to response - update authorizer to v2 response
- Loading branch information
Showing
11 changed files
with
16,200 additions
and
16,195 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
import { APIGatewayRequestAuthorizerHandler } from 'aws-lambda'; | ||
import { isTokenValid } from '@utils/api/apiAuth'; | ||
import { APIGatewayRequestSimpleAuthorizerHandlerV2 } from 'aws-lambda'; | ||
|
||
export const handler: APIGatewayRequestAuthorizerHandler = async (event) => { | ||
const authorization = event.headers?.['Authorization'] || ''; | ||
export const handler: APIGatewayRequestSimpleAuthorizerHandlerV2 = async (event) => { | ||
const authorization = event.headers?.['authorization'] || ''; | ||
|
||
// removing the initial "Bearer " | ||
const token = authorization.substring(7); | ||
const isAuthorized = isTokenValid(token); | ||
|
||
// ref: https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html#http-api-lambda-authorizer.payload-format-response | ||
return { | ||
principalId: 'simpleAuthorizerPrincipal', // principal user identification associated with the token sent by the client - let's hardcode for simplicity | ||
policyDocument: { | ||
Version: '2012-10-17', | ||
Statement: [ | ||
{ | ||
Effect: isAuthorized ? 'Allow' : 'Deny', | ||
Action: ['execute-api:Invoke'], | ||
Resource: ['*'], // all resources in this project - for this purpose this is fine | ||
}, | ||
], | ||
}, | ||
isAuthorized: isAuthorized, | ||
context: {}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters