Skip to content

Commit 719f33e

Browse files
author
Niranjan Jayakar
authoredNov 30, 2021
chore(apigatewayv2-authorizers): re-organize authorizer api (#17772)
This is a follow on to a previous commit 29039e8. Update the ergonomics of the authorizer construct APIs to be aligned with the rest of the module, specifically the integration construct APIs. The API now takes the construct id and the integration target as part of the constructor, instead of in the props class. In most cases, except in the case of jwt, all properties in the props struct become optional, which improves API ergonomics. It also removes the need for `authorizerName` property to be required. BREAKING CHANGE: The default value for the prop `authorizerName` in `HttpJwtAuthorizerProps` has changed. * **apigatewayv2-authorizers:** `HttpJwtAuthorizer` now takes the construct id and the target jwt issuer as part of its constructor. * **apigatewayv2-authorizers:** `HttpLambdaAuthorizer` now takes the construct id and the target lambda function handler as part of its constructor. * **apigatewayv2-authorizers:** The default value for the prop `authorizerName` in `HttpUserPoolAuthorizerProps` has changed. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 1799f7e commit 719f33e

File tree

11 files changed

+82
-107
lines changed

11 files changed

+82
-107
lines changed
 

‎packages/@aws-cdk/aws-apigatewayv2-authorizers/README.md

+8-14
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ In the example below, all routes will require the `manage:books` scope present i
4848
```ts
4949
import { HttpJwtAuthorizer } from '@aws-cdk/aws-apigatewayv2-authorizers';
5050

51-
const authorizer = new HttpJwtAuthorizer({
51+
const issuer = 'https://test.us.auth0.com';
52+
const authorizer = new HttpJwtAuthorizer('DefaultAuthorizer', issuer, {
5253
jwtAudience: ['3131231'],
53-
jwtIssuer: 'https://test.us.auth0.com',
5454
});
5555

5656
const api = new apigwv2.HttpApi(this, 'HttpApi', {
@@ -73,9 +73,9 @@ The example below showcases default authorization, along with route authorizatio
7373
import { HttpJwtAuthorizer } from '@aws-cdk/aws-apigatewayv2-authorizers';
7474
import { HttpUrlIntegration } from '@aws-cdk/aws-apigatewayv2-integrations';
7575

76-
const authorizer = new HttpJwtAuthorizer({
76+
const issuer = 'https://test.us.auth0.com';
77+
const authorizer = new HttpJwtAuthorizer('DefaultAuthorizer', issuer, {
7778
jwtAudience: ['3131231'],
78-
jwtIssuer: 'https://test.us.auth0.com',
7979
});
8080

8181
const api = new apigwv2.HttpApi(this, 'HttpApi', {
@@ -130,9 +130,9 @@ Clients that fail authorization are presented with either 2 responses:
130130
import { HttpJwtAuthorizer } from '@aws-cdk/aws-apigatewayv2-authorizers';
131131
import { HttpUrlIntegration } from '@aws-cdk/aws-apigatewayv2-integrations';
132132

133-
const authorizer = new HttpJwtAuthorizer({
133+
const issuer = 'https://test.us.auth0.com';
134+
const authorizer = new HttpJwtAuthorizer('BooksAuthorizer', issuer, {
134135
jwtAudience: ['3131231'],
135-
jwtIssuer: 'https://test.us.auth0.com',
136136
});
137137

138138
const api = new apigwv2.HttpApi(this, 'HttpApi');
@@ -158,12 +158,8 @@ import { HttpUserPoolAuthorizer } from '@aws-cdk/aws-apigatewayv2-authorizers';
158158
import { HttpUrlIntegration } from '@aws-cdk/aws-apigatewayv2-integrations';
159159

160160
const userPool = new cognito.UserPool(this, 'UserPool');
161-
const userPoolClient = userPool.addClient('UserPoolClient');
162161

163-
const authorizer = new HttpUserPoolAuthorizer({
164-
userPool,
165-
userPoolClients: [userPoolClient],
166-
});
162+
const authorizer = new HttpUserPoolAuthorizer('BooksAuthorizer', userPool);
167163

168164
const api = new apigwv2.HttpApi(this, 'HttpApi');
169165

@@ -188,10 +184,8 @@ import { HttpUrlIntegration } from '@aws-cdk/aws-apigatewayv2-integrations';
188184
// This function handles your auth logic
189185
declare const authHandler: lambda.Function;
190186

191-
const authorizer = new HttpLambdaAuthorizer({
192-
authorizerName: 'lambda-authorizer',
187+
const authorizer = new HttpLambdaAuthorizer('BooksAuthorizer', authHandler, {
193188
responseTypes: [HttpLambdaResponseType.SIMPLE], // Define if returns simple and/or iam response
194-
handler: authHandler,
195189
});
196190

197191
const api = new apigwv2.HttpApi(this, 'HttpApi');

‎packages/@aws-cdk/aws-apigatewayv2-authorizers/lib/http/jwt.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
HttpRouteAuthorizerConfig,
66
IHttpRouteAuthorizer,
77
} from '@aws-cdk/aws-apigatewayv2';
8-
import { Token } from '@aws-cdk/core';
98

109
/**
1110
* Properties to initialize HttpJwtAuthorizer.
@@ -14,7 +13,7 @@ export interface HttpJwtAuthorizerProps {
1413

1514
/**
1615
* The name of the authorizer
17-
* @default 'JwtAuthorizer'
16+
* @default - same value as `id` passed in the constructor
1817
*/
1918
readonly authorizerName?: string;
2019

@@ -30,11 +29,6 @@ export interface HttpJwtAuthorizerProps {
3029
* A valid JWT must provide an aud that matches at least one entry in this list.
3130
*/
3231
readonly jwtAudience: string[]
33-
34-
/**
35-
* The base domain of the identity provider that issues JWT.
36-
*/
37-
readonly jwtIssuer: string;
3832
}
3933

4034
/**
@@ -44,21 +38,27 @@ export interface HttpJwtAuthorizerProps {
4438
export class HttpJwtAuthorizer implements IHttpRouteAuthorizer {
4539
private authorizer?: HttpAuthorizer;
4640

47-
constructor(private readonly props: HttpJwtAuthorizerProps) {
41+
/**
42+
* Initialize a JWT authorizer to be bound with HTTP route.
43+
* @param id The id of the underlying construct
44+
* @param jwtIssuer The base domain of the identity provider that issues JWT
45+
* @param props Properties to configure the authorizer
46+
*/
47+
constructor(
48+
private readonly id: string,
49+
private readonly jwtIssuer: string,
50+
private readonly props: HttpJwtAuthorizerProps) {
4851
}
4952

5053
public bind(options: HttpRouteAuthorizerBindOptions): HttpRouteAuthorizerConfig {
5154
if (!this.authorizer) {
52-
const id = this.props.authorizerName && !Token.isUnresolved(this.props.authorizerName) ?
53-
this.props.authorizerName : 'JwtAuthorizer';
54-
55-
this.authorizer = new HttpAuthorizer(options.scope, id, {
55+
this.authorizer = new HttpAuthorizer(options.scope, this.id, {
5656
httpApi: options.route.httpApi,
5757
identitySource: this.props.identitySource ?? ['$request.header.Authorization'],
5858
type: HttpAuthorizerType.JWT,
59-
authorizerName: this.props.authorizerName,
59+
authorizerName: this.props.authorizerName ?? this.id,
6060
jwtAudience: this.props.jwtAudience,
61-
jwtIssuer: this.props.jwtIssuer,
61+
jwtIssuer: this.jwtIssuer,
6262
});
6363
}
6464

‎packages/@aws-cdk/aws-apigatewayv2-authorizers/lib/http/lambda.ts

+17-14
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ export enum HttpLambdaResponseType {
3232
export interface HttpLambdaAuthorizerProps {
3333

3434
/**
35-
* The name of the authorizer
35+
* Friendly authorizer name
36+
* @default - same value as `id` passed in the constructor.
3637
*/
37-
readonly authorizerName: string;
38+
readonly authorizerName?: string;
3839

3940
/**
4041
* The identity source for which authorization is requested.
@@ -43,11 +44,6 @@ export interface HttpLambdaAuthorizerProps {
4344
*/
4445
readonly identitySource?: string[];
4546

46-
/**
47-
* The lambda function used for authorization
48-
*/
49-
readonly handler: IFunction;
50-
5147
/**
5248
* How long APIGateway should cache the results. Max 1 hour.
5349
* Disable caching by setting this to `Duration.seconds(0)`.
@@ -76,7 +72,16 @@ export class HttpLambdaAuthorizer implements IHttpRouteAuthorizer {
7672
private authorizer?: HttpAuthorizer;
7773
private httpApi?: IHttpApi;
7874

79-
constructor(private readonly props: HttpLambdaAuthorizerProps) {
75+
/**
76+
* Initialize a lambda authorizer to be bound with HTTP route.
77+
* @param id The id of the underlying construct
78+
* @param pool The lambda function handler to use for authorization
79+
* @param props Properties to configure the authorizer
80+
*/
81+
constructor(
82+
private readonly id: string,
83+
private readonly handler: IFunction,
84+
private readonly props: HttpLambdaAuthorizerProps = {}) {
8085
}
8186

8287
public bind(options: HttpRouteAuthorizerBindOptions): HttpRouteAuthorizerConfig {
@@ -85,26 +90,24 @@ export class HttpLambdaAuthorizer implements IHttpRouteAuthorizer {
8590
}
8691

8792
if (!this.authorizer) {
88-
const id = this.props.authorizerName;
89-
9093
const responseTypes = this.props.responseTypes ?? [HttpLambdaResponseType.IAM];
9194
const enableSimpleResponses = responseTypes.includes(HttpLambdaResponseType.SIMPLE) || undefined;
9295

9396
this.httpApi = options.route.httpApi;
94-
this.authorizer = new HttpAuthorizer(options.scope, id, {
97+
this.authorizer = new HttpAuthorizer(options.scope, this.id, {
9598
httpApi: options.route.httpApi,
9699
identitySource: this.props.identitySource ?? [
97100
'$request.header.Authorization',
98101
],
99102
type: HttpAuthorizerType.LAMBDA,
100-
authorizerName: this.props.authorizerName,
103+
authorizerName: this.props.authorizerName ?? this.id,
101104
enableSimpleResponses,
102105
payloadFormatVersion: enableSimpleResponses ? AuthorizerPayloadVersion.VERSION_2_0 : AuthorizerPayloadVersion.VERSION_1_0,
103-
authorizerUri: lambdaAuthorizerArn(this.props.handler),
106+
authorizerUri: lambdaAuthorizerArn(this.handler),
104107
resultsCacheTtl: this.props.resultsCacheTtl ?? Duration.minutes(5),
105108
});
106109

107-
this.props.handler.addPermission(`${Names.nodeUniqueId(this.authorizer.node)}-Permission`, {
110+
this.handler.addPermission(`${Names.nodeUniqueId(this.authorizer.node)}-Permission`, {
108111
scope: options.scope as CoreConstruct,
109112
principal: new ServicePrincipal('apigateway.amazonaws.com'),
110113
sourceArn: Stack.of(options.route).formatArn({

‎packages/@aws-cdk/aws-apigatewayv2-authorizers/lib/http/user-pool.ts

+21-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
import { HttpAuthorizer, HttpAuthorizerType, HttpRouteAuthorizerBindOptions, HttpRouteAuthorizerConfig, IHttpRouteAuthorizer } from '@aws-cdk/aws-apigatewayv2';
22
import { IUserPool, IUserPoolClient } from '@aws-cdk/aws-cognito';
3-
import { Stack, Token } from '@aws-cdk/core';
3+
import { Stack } from '@aws-cdk/core';
44

55
/**
66
* Properties to initialize HttpUserPoolAuthorizer.
77
*/
88
export interface HttpUserPoolAuthorizerProps {
99
/**
1010
* The user pool clients that should be used to authorize requests with the user pool.
11+
* @default - a new client will be created for the given user pool
1112
*/
12-
readonly userPoolClients: IUserPoolClient[];
13-
14-
/**
15-
* The associated user pool
16-
*/
17-
readonly userPool: IUserPool;
13+
readonly userPoolClients?: IUserPoolClient[];
1814

1915
/**
2016
* The AWS region in which the user pool is present
@@ -23,8 +19,8 @@ export interface HttpUserPoolAuthorizerProps {
2319
readonly userPoolRegion?: string;
2420

2521
/**
26-
* The name of the authorizer
27-
* @default 'UserPoolAuthorizer'
22+
* Friendly name of the authorizer
23+
* @default - same value as `id` passed in the constructor
2824
*/
2925
readonly authorizerName?: string;
3026

@@ -43,21 +39,30 @@ export interface HttpUserPoolAuthorizerProps {
4339
export class HttpUserPoolAuthorizer implements IHttpRouteAuthorizer {
4440
private authorizer?: HttpAuthorizer;
4541

46-
constructor(private readonly props: HttpUserPoolAuthorizerProps) {
42+
/**
43+
* Initialize a Cognito user pool authorizer to be bound with HTTP route.
44+
* @param id The id of the underlying construct
45+
* @param pool The user pool to use for authorization
46+
* @param props Properties to configure the authorizer
47+
*/
48+
constructor(
49+
private readonly id: string,
50+
private readonly pool: IUserPool,
51+
private readonly props: HttpUserPoolAuthorizerProps = {}) {
4752
}
4853

4954
public bind(options: HttpRouteAuthorizerBindOptions): HttpRouteAuthorizerConfig {
5055
if (!this.authorizer) {
51-
const id = this.props.authorizerName && !Token.isUnresolved(this.props.authorizerName) ?
52-
this.props.authorizerName : 'UserPoolAuthorizer';
5356
const region = this.props.userPoolRegion ?? Stack.of(options.scope).region;
54-
this.authorizer = new HttpAuthorizer(options.scope, id, {
57+
const clients = this.props.userPoolClients ?? [this.pool.addClient('UserPoolAuthorizerClient')];
58+
59+
this.authorizer = new HttpAuthorizer(options.scope, this.id, {
5560
httpApi: options.route.httpApi,
5661
identitySource: this.props.identitySource ?? ['$request.header.Authorization'],
5762
type: HttpAuthorizerType.JWT,
58-
authorizerName: this.props.authorizerName,
59-
jwtAudience: this.props.userPoolClients.map((c) => c.userPoolClientId),
60-
jwtIssuer: `https://cognito-idp.${region}.amazonaws.com/${this.props.userPool.userPoolId}`,
63+
authorizerName: this.props.authorizerName ?? this.id,
64+
jwtAudience: clients.map((c) => c.userPoolClientId),
65+
jwtIssuer: `https://cognito-idp.${region}.amazonaws.com/${this.pool.userPoolId}`,
6166
});
6267
}
6368

‎packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/integ.lambda.expected.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"RouteKey": "GET /",
8080
"AuthorizationType": "CUSTOM",
8181
"AuthorizerId": {
82-
"Ref": "MyHttpApimysimpleauthorizer98398C16"
82+
"Ref": "MyHttpApiLambdaAuthorizerB8A0E2A4"
8383
},
8484
"Target": {
8585
"Fn::Join": [
@@ -94,7 +94,7 @@
9494
}
9595
}
9696
},
97-
"MyHttpApimysimpleauthorizer98398C16": {
97+
"MyHttpApiLambdaAuthorizerB8A0E2A4": {
9898
"Type": "AWS::ApiGatewayV2::Authorizer",
9999
"Properties": {
100100
"ApiId": {
@@ -133,7 +133,7 @@
133133
]
134134
}
135135
},
136-
"MyHttpApiAuthorizerIntegMyHttpApimysimpleauthorizer0F14A472PermissionF37EF5C8": {
136+
"MyHttpApiAuthorizerIntegMyHttpApiLambdaAuthorizerB89228D7Permission82260331": {
137137
"Type": "AWS::Lambda::Permission",
138138
"Properties": {
139139
"Action": "lambda:InvokeFunction",
@@ -166,7 +166,7 @@
166166
},
167167
"/authorizers/",
168168
{
169-
"Ref": "MyHttpApimysimpleauthorizer98398C16"
169+
"Ref": "MyHttpApiLambdaAuthorizerB8A0E2A4"
170170
}
171171
]
172172
]

‎packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/integ.lambda.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ const authHandler = new lambda.Function(stack, 'auth-function', {
2424
});
2525

2626

27-
const authorizer = new HttpLambdaAuthorizer({
27+
const authorizer = new HttpLambdaAuthorizer('LambdaAuthorizer', authHandler, {
2828
authorizerName: 'my-simple-authorizer',
2929
identitySource: ['$request.header.X-API-Key'],
30-
handler: authHandler,
3130
responseTypes: [HttpLambdaResponseType.SIMPLE],
3231
});
3332

‎packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/integ.user-pool.expected.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
"JwtConfiguration": {
109109
"Audience": [
110110
{
111-
"Ref": "userpoolmyclientFAD947AB"
111+
"Ref": "userpoolUserPoolAuthorizerClient6A7486E8"
112112
}
113113
],
114114
"Issuer": {
@@ -160,7 +160,7 @@
160160
"UpdateReplacePolicy": "Retain",
161161
"DeletionPolicy": "Retain"
162162
},
163-
"userpoolmyclientFAD947AB": {
163+
"userpoolUserPoolAuthorizerClient6A7486E8": {
164164
"Type": "AWS::Cognito::UserPoolClient",
165165
"Properties": {
166166
"UserPoolId": {

‎packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/integ.user-pool.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@ const httpApi = new HttpApi(stack, 'MyHttpApi');
2121

2222
const userPool = new cognito.UserPool(stack, 'userpool');
2323

24-
const userPoolClient = userPool.addClient('my-client');
25-
26-
const authorizer = new HttpUserPoolAuthorizer({
27-
userPool,
28-
userPoolClients: [userPoolClient],
29-
});
24+
const authorizer = new HttpUserPoolAuthorizer('UserPoolAuthorizer', userPool);
3025

3126
const handler = new lambda.Function(stack, 'lambda', {
3227
runtime: lambda.Runtime.NODEJS_12_X,

‎packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/jwt.test.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ describe('HttpJwtAuthorizer', () => {
1010
const stack = new Stack();
1111
const api = new HttpApi(stack, 'HttpApi');
1212

13-
const authorizer = new HttpJwtAuthorizer({
13+
const authorizer = new HttpJwtAuthorizer('BooksAuthorizer', 'https://test.us.auth0.com', {
1414
jwtAudience: ['3131231'],
15-
jwtIssuer: 'https://test.us.auth0.com',
1615
});
1716

1817
// WHEN
@@ -30,6 +29,7 @@ describe('HttpJwtAuthorizer', () => {
3029
Audience: ['3131231'],
3130
Issuer: 'https://test.us.auth0.com',
3231
},
32+
Name: 'BooksAuthorizer',
3333
});
3434
});
3535

@@ -38,9 +38,8 @@ describe('HttpJwtAuthorizer', () => {
3838
const stack = new Stack();
3939
const api = new HttpApi(stack, 'HttpApi');
4040

41-
const authorizer = new HttpJwtAuthorizer({
41+
const authorizer = new HttpJwtAuthorizer('BooksAuthorizer', 'https://test.us.auth0.com', {
4242
jwtAudience: ['3131231'],
43-
jwtIssuer: 'https://test.us.auth0.com',
4443
});
4544

4645
// WHEN

‎packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/lambda.test.ts

+6-18
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ describe('HttpLambdaAuthorizer', () => {
1818
handler: 'index.handler',
1919
});
2020

21-
const authorizer = new HttpLambdaAuthorizer({
22-
authorizerName: 'default-authorizer',
23-
handler,
24-
});
21+
const authorizer = new HttpLambdaAuthorizer('BooksAuthorizer', handler);
2522

2623
// WHEN
2724
api.addRoutes({
@@ -32,7 +29,7 @@ describe('HttpLambdaAuthorizer', () => {
3229

3330
// THEN
3431
Template.fromStack(stack).hasResourceProperties('AWS::ApiGatewayV2::Authorizer', {
35-
Name: 'default-authorizer',
32+
Name: 'BooksAuthorizer',
3633
AuthorizerType: 'REQUEST',
3734
AuthorizerResultTtlInSeconds: 300,
3835
AuthorizerPayloadFormatVersion: '1.0',
@@ -57,10 +54,8 @@ describe('HttpLambdaAuthorizer', () => {
5754
handler: 'index.handler',
5855
});
5956

60-
const authorizer = new HttpLambdaAuthorizer({
61-
authorizerName: 'my-simple-authorizer',
57+
const authorizer = new HttpLambdaAuthorizer('BooksAuthorizer', handler, {
6258
responseTypes: [HttpLambdaResponseType.SIMPLE],
63-
handler,
6459
});
6560

6661
// WHEN
@@ -88,10 +83,8 @@ describe('HttpLambdaAuthorizer', () => {
8883
handler: 'index.handler',
8984
});
9085

91-
const authorizer = new HttpLambdaAuthorizer({
92-
authorizerName: 'my-iam-authorizer',
86+
const authorizer = new HttpLambdaAuthorizer('BooksAuthorizer', handler, {
9387
responseTypes: [HttpLambdaResponseType.IAM],
94-
handler,
9588
});
9689

9790
// WHEN
@@ -119,10 +112,8 @@ describe('HttpLambdaAuthorizer', () => {
119112
handler: 'index.handler',
120113
});
121114

122-
const authorizer = new HttpLambdaAuthorizer({
123-
authorizerName: 'my-simple-iam-authorizer',
115+
const authorizer = new HttpLambdaAuthorizer('BooksAuthorizer', handler, {
124116
responseTypes: [HttpLambdaResponseType.IAM, HttpLambdaResponseType.SIMPLE],
125-
handler,
126117
});
127118

128119
// WHEN
@@ -150,10 +141,7 @@ describe('HttpLambdaAuthorizer', () => {
150141
handler: 'index.handler',
151142
});
152143

153-
const authorizer = new HttpLambdaAuthorizer({
154-
authorizerName: 'my-simple-authorizer',
155-
responseTypes: [HttpLambdaResponseType.SIMPLE],
156-
handler,
144+
const authorizer = new HttpLambdaAuthorizer('BooksAuthorizer', handler, {
157145
resultsCacheTtl: Duration.minutes(10),
158146
});
159147

‎packages/@aws-cdk/aws-apigatewayv2-authorizers/test/http/user-pool.test.ts

+5-13
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ describe('HttpUserPoolAuthorizer', () => {
1111
const stack = new Stack();
1212
const api = new HttpApi(stack, 'HttpApi');
1313
const userPool = new UserPool(stack, 'UserPool');
14-
const userPoolClient = userPool.addClient('UserPoolClient');
15-
const authorizer = new HttpUserPoolAuthorizer({
16-
userPool,
17-
userPoolClients: [userPoolClient],
18-
});
14+
const authorizer = new HttpUserPoolAuthorizer('BooksAuthorizer', userPool);
1915

2016
// WHEN
2117
api.addRoutes({
@@ -29,7 +25,7 @@ describe('HttpUserPoolAuthorizer', () => {
2925
AuthorizerType: 'JWT',
3026
IdentitySource: ['$request.header.Authorization'],
3127
JwtConfiguration: {
32-
Audience: [stack.resolve(userPoolClient.userPoolClientId)],
28+
Audience: [{ Ref: 'UserPoolUserPoolAuthorizerClient680A88B6' }],
3329
Issuer: {
3430
'Fn::Join': [
3531
'',
@@ -42,6 +38,7 @@ describe('HttpUserPoolAuthorizer', () => {
4238
],
4339
},
4440
},
41+
Name: 'BooksAuthorizer',
4542
});
4643
});
4744

@@ -50,11 +47,7 @@ describe('HttpUserPoolAuthorizer', () => {
5047
const stack = new Stack();
5148
const api = new HttpApi(stack, 'HttpApi');
5249
const userPool = new UserPool(stack, 'UserPool');
53-
const userPoolClient = userPool.addClient('UserPoolClient');
54-
const authorizer = new HttpUserPoolAuthorizer({
55-
userPool,
56-
userPoolClients: [userPoolClient],
57-
});
50+
const authorizer = new HttpUserPoolAuthorizer('UserPoolAuthorizer', userPool);
5851

5952
// WHEN
6053
api.addRoutes({
@@ -79,8 +72,7 @@ describe('HttpUserPoolAuthorizer', () => {
7972
const userPool = new UserPool(stack, 'UserPool');
8073
const userPoolClient1 = userPool.addClient('UserPoolClient1');
8174
const userPoolClient2 = userPool.addClient('UserPoolClient2');
82-
const authorizer = new HttpUserPoolAuthorizer({
83-
userPool,
75+
const authorizer = new HttpUserPoolAuthorizer('BooksAuthorizer', userPool, {
8476
userPoolClients: [userPoolClient1, userPoolClient2],
8577
});
8678

0 commit comments

Comments
 (0)
Please sign in to comment.