-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: openapi support for auth usecases (#949)
- Loading branch information
Showing
20 changed files
with
5,329 additions
and
8 deletions.
There are no files selected for viewing
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
106 changes: 106 additions & 0 deletions
106
tests/translator/input/api_with_auth_all_maximum_openapi_3.yaml
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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
Resources: | ||
MyApi: | ||
Type: "AWS::Serverless::Api" | ||
Properties: | ||
StageName: Prod | ||
OpenApiVersion: '3.0.1' | ||
Auth: | ||
DefaultAuthorizer: MyCognitoAuth | ||
Authorizers: | ||
MyCognitoAuth: | ||
UserPoolArn: arn:aws:1 | ||
Identity: | ||
Header: MyAuthorizationHeader | ||
ValidationExpression: myauthvalidationexpression | ||
|
||
MyCognitoAuthMultipleUserPools: | ||
UserPoolArn: | ||
- arn:aws:2 | ||
- arn:aws:3 | ||
Identity: | ||
Header: MyAuthorizationHeader2 | ||
ValidationExpression: myauthvalidationexpression2 | ||
|
||
MyLambdaTokenAuth: | ||
FunctionPayloadType: TOKEN | ||
FunctionArn: arn:aws | ||
FunctionInvokeRole: arn:aws:iam::123456789012:role/S3Access | ||
Identity: | ||
Header: MyCustomAuthHeader | ||
ValidationExpression: mycustomauthexpression | ||
ReauthorizeEvery: 20 | ||
|
||
MyLambdaTokenAuthNoneFunctionInvokeRole: | ||
FunctionArn: arn:aws | ||
FunctionInvokeRole: NONE | ||
Identity: | ||
ReauthorizeEvery: 0 | ||
|
||
MyLambdaRequestAuth: | ||
FunctionPayloadType: REQUEST | ||
FunctionArn: arn:aws | ||
FunctionInvokeRole: arn:aws:iam::123456789012:role/S3Access | ||
Identity: | ||
Headers: | ||
- Authorization1 | ||
QueryStrings: | ||
- Authorization2 | ||
StageVariables: | ||
- Authorization3 | ||
Context: | ||
- Authorization4 | ||
ReauthorizeEvery: 0 | ||
|
||
MyFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/thumbnails.zip | ||
Handler: index.handler | ||
Runtime: nodejs8.10 | ||
Events: | ||
WithNoAuthorizer: | ||
Type: Api | ||
Properties: | ||
RestApiId: !Ref MyApi | ||
Path: / | ||
Method: get | ||
Auth: | ||
Authorizer: NONE | ||
WithCognitoMultipleUserPoolsAuthorizer: | ||
Type: Api | ||
Properties: | ||
RestApiId: !Ref MyApi | ||
Path: /users | ||
Method: post | ||
Auth: | ||
Authorizer: MyCognitoAuthMultipleUserPools | ||
WithLambdaTokenAuthorizer: | ||
Type: Api | ||
Properties: | ||
RestApiId: !Ref MyApi | ||
Path: /users | ||
Method: get | ||
Auth: | ||
Authorizer: MyLambdaTokenAuth | ||
WithLambdaTokenAuthorizer: | ||
Type: Api | ||
Properties: | ||
RestApiId: !Ref MyApi | ||
Path: /users | ||
Method: patch | ||
Auth: | ||
Authorizer: MyLambdaTokenAuthNoneFunctionInvokeRole | ||
WithLambdaRequestAuthorizer: | ||
Type: Api | ||
Properties: | ||
RestApiId: !Ref MyApi | ||
Path: /users | ||
Method: delete | ||
Auth: | ||
Authorizer: MyLambdaRequestAuth | ||
WithDefaultAuthorizer: | ||
Type: Api | ||
Properties: | ||
RestApiId: !Ref MyApi | ||
Path: /users | ||
Method: put |
81 changes: 81 additions & 0 deletions
81
tests/translator/input/api_with_auth_all_minimum_openapi.yaml
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
Globals: | ||
Api: | ||
OpenApiVersion: '3.0.1' | ||
Resources: | ||
MyApiWithCognitoAuth: | ||
Type: "AWS::Serverless::Api" | ||
Properties: | ||
StageName: Prod | ||
Auth: | ||
DefaultAuthorizer: MyCognitoAuth | ||
Authorizers: | ||
MyCognitoAuth: | ||
UserPoolArn: !GetAtt MyUserPool.Arn | ||
|
||
MyApiWithLambdaTokenAuth: | ||
Type: "AWS::Serverless::Api" | ||
Properties: | ||
StageName: Prod | ||
Auth: | ||
DefaultAuthorizer: MyLambdaTokenAuth | ||
Authorizers: | ||
MyLambdaTokenAuth: | ||
FunctionArn: !GetAtt MyAuthFn.Arn | ||
|
||
MyApiWithLambdaRequestAuth: | ||
Type: "AWS::Serverless::Api" | ||
Properties: | ||
StageName: Prod | ||
Auth: | ||
DefaultAuthorizer: MyLambdaRequestAuth | ||
Authorizers: | ||
MyLambdaRequestAuth: | ||
FunctionPayloadType: REQUEST | ||
FunctionArn: !GetAtt MyAuthFn.Arn | ||
Identity: | ||
Headers: | ||
- Authorization1 | ||
MyAuthFn: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://bucketname/thumbnails.zip | ||
Handler: index.handler | ||
Runtime: nodejs8.10 | ||
MyFn: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://bucketname/thumbnails.zip | ||
Handler: index.handler | ||
Runtime: nodejs8.10 | ||
Events: | ||
Cognito: | ||
Type: Api | ||
Properties: | ||
RestApiId: !Ref MyApiWithCognitoAuth | ||
Method: get | ||
Path: /cognito | ||
LambdaToken: | ||
Type: Api | ||
Properties: | ||
RestApiId: !Ref MyApiWithLambdaTokenAuth | ||
Method: get | ||
Path: /lambda-token | ||
LambdaRequest: | ||
Type: Api | ||
Properties: | ||
RestApiId: !Ref MyApiWithLambdaRequestAuth | ||
Method: get | ||
Path: /lambda-request | ||
MyUserPool: | ||
Type: AWS::Cognito::UserPool | ||
Properties: | ||
UserPoolName: UserPoolName | ||
Policies: | ||
PasswordPolicy: | ||
MinimumLength: 8 | ||
UsernameAttributes: | ||
Schema: | ||
- AttributeDataType: String | ||
Name: email | ||
Required: false |
58 changes: 58 additions & 0 deletions
58
tests/translator/input/api_with_openapi_definition_body_no_flag.yaml
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
Globals: | ||
Api: | ||
Name: "some api" | ||
CacheClusterEnabled: True | ||
CacheClusterSize: "1.6" | ||
Auth: | ||
DefaultAuthorizer: MyCognitoAuth | ||
Authorizers: | ||
MyCognitoAuth: | ||
UserPoolArn: !GetAtt MyUserPool.Arn | ||
Variables: | ||
SomeVar: Value | ||
|
||
Resources: | ||
ImplicitApiFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.gethtml | ||
Runtime: nodejs4.3 | ||
Events: | ||
GetHtml: | ||
Type: Api | ||
Properties: | ||
Path: / | ||
Method: get | ||
|
||
ExplicitApi: | ||
Type: AWS::Serverless::Api | ||
Properties: | ||
StageName: SomeStage | ||
DefinitionBody: | ||
openapi: 3.1.1 | ||
info: | ||
version: '1.0' | ||
title: !Ref AWS::StackName | ||
paths: | ||
"/": | ||
get: | ||
x-amazon-apigateway-integration: | ||
httpMethod: POST | ||
type: aws_proxy | ||
uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations | ||
responses: {} | ||
|
||
MyUserPool: | ||
Type: AWS::Cognito::UserPool | ||
Properties: | ||
UserPoolName: UserPoolName | ||
Policies: | ||
PasswordPolicy: | ||
MinimumLength: 8 | ||
UsernameAttributes: | ||
Schema: | ||
- AttributeDataType: String | ||
Name: email | ||
Required: false |
59 changes: 59 additions & 0 deletions
59
tests/translator/input/api_with_swagger_and_openapi_with_auth.yaml
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Globals: | ||
Api: | ||
Name: "some api" | ||
CacheClusterEnabled: True | ||
CacheClusterSize: "1.6" | ||
Auth: | ||
DefaultAuthorizer: MyCognitoAuth | ||
Authorizers: | ||
MyCognitoAuth: | ||
UserPoolArn: !GetAtt MyUserPool.Arn | ||
Variables: | ||
SomeVar: Value | ||
|
||
Resources: | ||
ImplicitApiFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: s3://sam-demo-bucket/member_portal.zip | ||
Handler: index.gethtml | ||
Runtime: nodejs4.3 | ||
Events: | ||
GetHtml: | ||
Type: Api | ||
Properties: | ||
Path: / | ||
Method: get | ||
|
||
ExplicitApi: | ||
Type: AWS::Serverless::Api | ||
Properties: | ||
StageName: SomeStage | ||
DefinitionBody: | ||
openapi: 3.1.1 | ||
swagger: 2.0 | ||
info: | ||
version: '1.0' | ||
title: !Ref AWS::StackName | ||
paths: | ||
"/": | ||
get: | ||
x-amazon-apigateway-integration: | ||
httpMethod: POST | ||
type: aws_proxy | ||
uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${ImplicitApiFunction.Arn}/invocations | ||
responses: {} | ||
|
||
MyUserPool: | ||
Type: AWS::Cognito::UserPool | ||
Properties: | ||
UserPoolName: UserPoolName | ||
Policies: | ||
PasswordPolicy: | ||
MinimumLength: 8 | ||
UsernameAttributes: | ||
Schema: | ||
- AttributeDataType: String | ||
Name: email | ||
Required: false |
Oops, something went wrong.