Skip to content

Commit 6018956

Browse files
committed
implement auth to the construct model
1 parent 5d42784 commit 6018956

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/rest-api-construct/src/construct.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class RestApiConstruct extends Construct {
5656
// Add resource and methods for this route
5757
const resource = this.addNestedResource(this.api.root, path);
5858
for (const method of methods) {
59-
resource.addMethod(method, new apiGateway.LambdaIntegration(handler));
59+
resource.addMethod(method.method, new apiGateway.LambdaIntegration(handler));
6060
}
6161
}
6262
}

packages/rest-api-construct/src/types.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,22 @@ export type RestApiConstructProps = {
1616
apiProps: RestApiPathConfig[];
1717
};
1818

19+
export type AuthorizerConfig =
20+
| { type: 'none' } // public
21+
| { type: 'userPool' } // signed-in users
22+
| { type: 'userPool'; groups: string[] }; // signed-in + group restriction
23+
24+
25+
export type MethodsProps = {
26+
method: HttpMethod;
27+
authorizer?: AuthorizerConfig;
28+
};
29+
1930
export type RestApiPathConfig = {
2031
path: string;
21-
methods: HttpMethod[];
32+
methods: MethodsProps[];
2233
lambdaEntry: LambdaSource;
34+
defaultAuthorizer?: AuthorizerConfig;
2335
};
2436

2537
export type HttpMethod =

0 commit comments

Comments
 (0)