Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(apigatewayv2): http api - default authorizer options #13172

Merged
merged 31 commits into from Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
253a9b0
feat(apigatewayv2): http api - default authorizer options
iRoachie Feb 21, 2021
105684c
docs: add example of default settings
iRoachie Feb 21, 2021
a953e06
Update packages/@aws-cdk/aws-apigatewayv2/lib/http/api.ts
iRoachie Feb 25, 2021
51132a3
change route behaviour to override default scopes
iRoachie Feb 25, 2021
2404a77
Add NoneAuthorizer
iRoachie Feb 25, 2021
4dceadf
Add docs for NoneAuthorizer
iRoachie Feb 25, 2021
3ec0ca9
Merge branch 'master' into ft/default-authorizer
iRoachie Feb 25, 2021
bae9a27
Add optional default documentation
iRoachie Feb 25, 2021
764552c
Update packages/@aws-cdk/aws-apigatewayv2/lib/http/api.ts
iRoachie Feb 26, 2021
19b1383
Update packages/@aws-cdk/aws-apigatewayv2/lib/http/api.ts
iRoachie Feb 26, 2021
8577089
prefix internal variable with default keyword
iRoachie Feb 26, 2021
8e071ae
Update packages/@aws-cdk/aws-apigatewayv2/lib/http/api.ts
iRoachie Feb 26, 2021
f4dd89b
Update packages/@aws-cdk/aws-apigatewayv2/lib/http/api.ts
iRoachie Feb 26, 2021
a97a90e
relocate NoneAuthorizer
iRoachie Feb 26, 2021
df0bae2
Update packages/@aws-cdk/aws-apigatewayv2/lib/http/api.ts
iRoachie Feb 26, 2021
32aa124
don't set empty authorizationScopes
iRoachie Feb 26, 2021
9eb1403
update integ test
iRoachie Feb 26, 2021
0345169
update integ tests
iRoachie Feb 26, 2021
ab4a090
Merge branch 'master' into ft/default-authorizer
iRoachie Feb 27, 2021
84bf186
update integ test
iRoachie Feb 27, 2021
c221da5
Merge branch 'master' into ft/default-authorizer
iRoachie Mar 6, 2021
07e1569
Update packages/@aws-cdk/aws-apigatewayv2/lib/http/api.ts
iRoachie Mar 10, 2021
f5ac48a
docs: update authorizationr readme
iRoachie Mar 10, 2021
1660110
Update packages/@aws-cdk/aws-apigatewayv2-authorizers/README.md
iRoachie Mar 10, 2021
f56c52a
Update packages/@aws-cdk/aws-apigatewayv2-authorizers/README.md
iRoachie Mar 10, 2021
59f3d52
Update packages/@aws-cdk/aws-apigatewayv2-authorizers/README.md
iRoachie Mar 10, 2021
62e7e24
Merge branch 'master' into ft/default-authorizer
mergify[bot] Mar 10, 2021
6a3a44b
Merge branch 'master' into ft/default-authorizer
iRoachie Mar 14, 2021
36593ee
update integ
iRoachie Mar 15, 2021
1805a21
Merge branch 'master' into ft/default-authorizer
mergify[bot] Mar 17, 2021
c96dfe5
Merge branch 'master' into ft/default-authorizer
mergify[bot] Mar 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions packages/@aws-cdk/aws-apigatewayv2-authorizers/README.md
Expand Up @@ -28,6 +28,37 @@ classified into Lambda Authorizers, JWT authorizers and standard AWS IAM roles a
available at [Controlling and managing access to an HTTP
API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-access-control.html).

Authorizers, and scopes can either be applied to the Gateway (applied to all routes) or specifically for each route.

The example below applies the authorizer to all routes.

```ts
const authorizer = new HttpJwtAuthorizer({
iRoachie marked this conversation as resolved.
Show resolved Hide resolved
jwtAudience: ['3131231'],
jwtIssuer: 'https://test.us.auth0.com',
});

const api = new HttpApi(stack, 'HttpApi', {
defaultAuthorizer: authorizer,
defaultAuthorizationScopes: ['read:books']
});

api.addRoutes({
integration: new HttpProxyIntegration({
url: 'https://add-books-proxy.myproxy.internal',
}),
path: '/books', // This route will inherit the authorizer and scopes from the gateway
});

api.addRoutes({
integration: new HttpProxyIntegration({
url: 'https://get-books-proxy.myproxy.internal',
}),
path: '/books',
authorizer: new NoneAuthorizer(), // This route will remove the default authorizer from the gateway
});
```

## JWT Authorizers

JWT authorizers allow the use of JSON Web Tokens (JWTs) as part of [OpenID Connect](https://openid.net/specs/openid-connect-core-1_0.html) and [OAuth 2.0](https://oauth.net/2/) frameworks to allow and restrict clients from accessing HTTP APIs.
Expand Down
Expand Up @@ -54,14 +54,29 @@
}
}
},
"MyHttpApiGETHttpIntegration6f095b8469365f72e33fa33d9711b140516EBE31": {
"Type": "AWS::ApiGatewayV2::Integration",
"Properties": {
"ApiId": {
"Ref": "MyHttpApi8AEAAC21"
},
"IntegrationType": "AWS_PROXY",
"IntegrationUri": {
"Fn::GetAtt": [
"lambda8B5974B5",
"Arn"
]
},
"PayloadFormatVersion": "2.0"
}
},
"MyHttpApiGETE0EFC6F8": {
"Type": "AWS::ApiGatewayV2::Route",
"Properties": {
"ApiId": {
"Ref": "MyHttpApi8AEAAC21"
},
"RouteKey": "GET /",
"AuthorizationScopes": [],
"AuthorizationType": "JWT",
"AuthorizerId": {
"Ref": "MyHttpApiUserPoolAuthorizer8754262B"
Expand All @@ -79,22 +94,6 @@
}
}
},
"MyHttpApiGETHttpIntegration6f095b8469365f72e33fa33d9711b140516EBE31": {
"Type": "AWS::ApiGatewayV2::Integration",
"Properties": {
"ApiId": {
"Ref": "MyHttpApi8AEAAC21"
},
"IntegrationType": "AWS_PROXY",
"IntegrationUri": {
"Fn::GetAtt": [
"lambda8B5974B5",
"Arn"
]
},
"PayloadFormatVersion": "2.0"
}
},
"MyHttpApiUserPoolAuthorizer8754262B": {
"Type": "AWS::ApiGatewayV2::Authorizer",
"Properties": {
Expand Down
Expand Up @@ -608,14 +608,31 @@
"ProtocolType": "HTTP"
}
},
"HttpProxyPrivateApiDefaultRouteHttpIntegration1a580b19954e4317026ffbce1f7d5ade7A32685B": {
"Type": "AWS::ApiGatewayV2::Integration",
"Properties": {
"ApiId": {
"Ref": "HttpProxyPrivateApiA55E154D"
},
"IntegrationType": "HTTP_PROXY",
"ConnectionId": {
"Ref": "HttpProxyPrivateApiVpcLink190366CAE"
},
"ConnectionType": "VPC_LINK",
"IntegrationMethod": "ANY",
"IntegrationUri": {
"Ref": "lblistener657ADDEC"
},
"PayloadFormatVersion": "1.0"
}
},
"HttpProxyPrivateApiDefaultRoute1BDCA252": {
"Type": "AWS::ApiGatewayV2::Route",
"Properties": {
"ApiId": {
"Ref": "HttpProxyPrivateApiA55E154D"
},
"RouteKey": "$default",
"AuthorizationScopes": [],
"Target": {
"Fn::Join": [
"",
Expand Down Expand Up @@ -647,24 +664,6 @@
"SecurityGroupIds": []
}
},
"HttpProxyPrivateApiDefaultRouteHttpIntegration1a580b19954e4317026ffbce1f7d5ade7A32685B": {
"Type": "AWS::ApiGatewayV2::Integration",
"Properties": {
"ApiId": {
"Ref": "HttpProxyPrivateApiA55E154D"
},
"IntegrationType": "HTTP_PROXY",
"ConnectionId": {
"Ref": "HttpProxyPrivateApiVpcLink190366CAE"
},
"ConnectionType": "VPC_LINK",
"IntegrationMethod": "ANY",
"IntegrationUri": {
"Ref": "lblistener657ADDEC"
},
"PayloadFormatVersion": "1.0"
}
},
"HttpProxyPrivateApiDefaultStage18B3706E": {
"Type": "AWS::ApiGatewayV2::Stage",
"Properties": {
Expand Down
Expand Up @@ -94,14 +94,29 @@
}
}
},
"LambdaProxyApiDefaultRouteHttpIntegration70df0ec52c3e3b6bbc96e64ce3a05f24EE575CBA": {
"Type": "AWS::ApiGatewayV2::Integration",
"Properties": {
"ApiId": {
"Ref": "LambdaProxyApi67594471"
},
"IntegrationType": "AWS_PROXY",
"IntegrationUri": {
"Fn::GetAtt": [
"AlwaysSuccess099EAB05",
"Arn"
]
},
"PayloadFormatVersion": "2.0"
}
},
"LambdaProxyApiDefaultRoute1EB30A46": {
"Type": "AWS::ApiGatewayV2::Route",
"Properties": {
"ApiId": {
"Ref": "LambdaProxyApi67594471"
},
"RouteKey": "$default",
"AuthorizationScopes": [],
"Target": {
"Fn::Join": [
"",
Expand All @@ -115,22 +130,6 @@
}
}
},
"LambdaProxyApiDefaultRouteHttpIntegration70df0ec52c3e3b6bbc96e64ce3a05f24EE575CBA": {
"Type": "AWS::ApiGatewayV2::Integration",
"Properties": {
"ApiId": {
"Ref": "LambdaProxyApi67594471"
},
"IntegrationType": "AWS_PROXY",
"IntegrationUri": {
"Fn::GetAtt": [
"AlwaysSuccess099EAB05",
"Arn"
]
},
"PayloadFormatVersion": "2.0"
}
},
"LambdaProxyApiDefaultStage07C38681": {
"Type": "AWS::ApiGatewayV2::Stage",
"Properties": {
Expand All @@ -148,27 +147,6 @@
"ProtocolType": "HTTP"
}
},
"HttpProxyApiDefaultRoute8AF66B5C": {
"Type": "AWS::ApiGatewayV2::Route",
"Properties": {
"ApiId": {
"Ref": "HttpProxyApiD0217C67"
},
"RouteKey": "$default",
"AuthorizationScopes": [],
"Target": {
"Fn::Join": [
"",
[
"integrations/",
{
"Ref": "HttpProxyApiDefaultRouteHttpIntegration8eeecf9ecdb91f31bebf6bd54fb711a41921AB82"
}
]
]
}
}
},
"HttpProxyApiDefaultRouteHttpIntegration8eeecf9ecdb91f31bebf6bd54fb711a41921AB82": {
"Type": "AWS::ApiGatewayV2::Integration",
"Properties": {
Expand Down Expand Up @@ -200,6 +178,26 @@
"PayloadFormatVersion": "1.0"
}
},
"HttpProxyApiDefaultRoute8AF66B5C": {
"Type": "AWS::ApiGatewayV2::Route",
"Properties": {
"ApiId": {
"Ref": "HttpProxyApiD0217C67"
},
"RouteKey": "$default",
"Target": {
"Fn::Join": [
"",
[
"integrations/",
{
"Ref": "HttpProxyApiDefaultRouteHttpIntegration8eeecf9ecdb91f31bebf6bd54fb711a41921AB82"
}
]
]
}
}
},
"HttpProxyApiDefaultStageA88F9DE3": {
"Type": "AWS::ApiGatewayV2::Stage",
"Properties": {
Expand Down
Expand Up @@ -94,14 +94,29 @@
}
}
},
"LambdaProxyApiDefaultRouteHttpIntegration70df0ec52c3e3b6bbc96e64ce3a05f24EE575CBA": {
"Type": "AWS::ApiGatewayV2::Integration",
"Properties": {
"ApiId": {
"Ref": "LambdaProxyApi67594471"
},
"IntegrationType": "AWS_PROXY",
"IntegrationUri": {
"Fn::GetAtt": [
"AlwaysSuccess099EAB05",
"Arn"
]
},
"PayloadFormatVersion": "2.0"
}
},
"LambdaProxyApiDefaultRoute1EB30A46": {
"Type": "AWS::ApiGatewayV2::Route",
"Properties": {
"ApiId": {
"Ref": "LambdaProxyApi67594471"
},
"RouteKey": "$default",
"AuthorizationScopes": [],
"Target": {
"Fn::Join": [
"",
Expand All @@ -115,22 +130,6 @@
}
}
},
"LambdaProxyApiDefaultRouteHttpIntegration70df0ec52c3e3b6bbc96e64ce3a05f24EE575CBA": {
"Type": "AWS::ApiGatewayV2::Integration",
"Properties": {
"ApiId": {
"Ref": "LambdaProxyApi67594471"
},
"IntegrationType": "AWS_PROXY",
"IntegrationUri": {
"Fn::GetAtt": [
"AlwaysSuccess099EAB05",
"Arn"
]
},
"PayloadFormatVersion": "2.0"
}
},
"LambdaProxyApiDefaultStage07C38681": {
"Type": "AWS::ApiGatewayV2::Stage",
"Properties": {
Expand Down
Expand Up @@ -573,14 +573,31 @@
"ProtocolType": "HTTP"
}
},
"HttpProxyPrivateApiDefaultRouteHttpIntegration1a580b19954e4317026ffbce1f7d5ade7A32685B": {
"Type": "AWS::ApiGatewayV2::Integration",
"Properties": {
"ApiId": {
"Ref": "HttpProxyPrivateApiA55E154D"
},
"IntegrationType": "HTTP_PROXY",
"ConnectionId": {
"Ref": "HttpProxyPrivateApiVpcLink190366CAE"
},
"ConnectionType": "VPC_LINK",
"IntegrationMethod": "ANY",
"IntegrationUri": {
"Ref": "lblistener657ADDEC"
},
"PayloadFormatVersion": "1.0"
}
},
"HttpProxyPrivateApiDefaultRoute1BDCA252": {
"Type": "AWS::ApiGatewayV2::Route",
"Properties": {
"ApiId": {
"Ref": "HttpProxyPrivateApiA55E154D"
},
"RouteKey": "$default",
"AuthorizationScopes": [],
"Target": {
"Fn::Join": [
"",
Expand Down Expand Up @@ -612,24 +629,6 @@
"SecurityGroupIds": []
}
},
"HttpProxyPrivateApiDefaultRouteHttpIntegration1a580b19954e4317026ffbce1f7d5ade7A32685B": {
"Type": "AWS::ApiGatewayV2::Integration",
"Properties": {
"ApiId": {
"Ref": "HttpProxyPrivateApiA55E154D"
},
"IntegrationType": "HTTP_PROXY",
"ConnectionId": {
"Ref": "HttpProxyPrivateApiVpcLink190366CAE"
},
"ConnectionType": "VPC_LINK",
"IntegrationMethod": "ANY",
"IntegrationUri": {
"Ref": "lblistener657ADDEC"
},
"PayloadFormatVersion": "1.0"
}
},
"HttpProxyPrivateApiDefaultStage18B3706E": {
"Type": "AWS::ApiGatewayV2::Stage",
"Properties": {
Expand Down