Skip to content

Commit efcf08b

Browse files
committed
add support for http api auth
1 parent 32eaab3 commit efcf08b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)
66

7+
## [3.4.0]  (2020-05-10)
8+
9+
### Added
10+
11+
- Added support for API Gateway v2 HTTP API Auth property
12+
713
## [3.3.3]  (2020-05-08)
814

915
### Changed
@@ -207,6 +213,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/),
207213
- Update older libraries
208214
- Now publish from Git tags instead of master pushes
209215

216+
[3.4.0]: https://github.com/manwaring/lambda-wrapper/compare/v3.3.3...v3.4.0
210217
[3.3.3]: https://github.com/manwaring/lambda-wrapper/compare/v3.3.1...v3.3.3
211218
[3.3.2]: https://github.com/manwaring/lambda-wrapper/compare/v3.3.1...v3.3.2
212219
[3.3.1]: https://github.com/manwaring/lambda-wrapper/compare/v3.3.0...v3.3.1

src/api/parser.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ export class Request {
1111
const event = this.event;
1212
const path = event.pathParameters ? event.pathParameters : undefined;
1313
const query = event.queryStringParameters ? event.queryStringParameters : undefined;
14-
const auth = event.requestContext && event.requestContext.authorizer ? event.requestContext.authorizer : undefined;
14+
const auth = this.getAuth();
1515
const headers = event.headers ? event.headers : undefined;
1616
const body = new Body(event.body, headers).getParsedBody();
1717
const TEST_REQUEST_HEADER = process.env.TEST_REQUEST_HEADER || 'Test-Request';
1818
const testRequest = headers && headers[TEST_REQUEST_HEADER] ? JSON.parse(headers[TEST_REQUEST_HEADER]) : false;
1919
metrics.common({ body, path, query, auth, headers, testRequest });
2020
return { body, path, query, auth, headers, testRequest };
2121
}
22+
23+
private getAuth() {
24+
const authorizer = this.event?.requestContext?.authorizer;
25+
// @ts-ignore
26+
const httpApiAuth = this.event.auth;
27+
return authorizer ? authorizer : httpApiAuth;
28+
}
2229
}
2330

2431
export class Body {

0 commit comments

Comments
 (0)