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

chore(apigateway): improve docs and default value settings for identity source in authorizer #28214

Merged
merged 4 commits into from
Dec 4, 2023

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Dec 1, 2023

Addressed the following points about Authorizer's identitySource property.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team December 1, 2023 07:56
@github-actions github-actions bot added p2 star-contributor [Pilot] contributed between 25-49 PRs to the CDK labels Dec 1, 2023
@@ -78,7 +80,7 @@ export class CognitoUserPoolsAuthorizer extends Authorizer implements IAuthorize
type: 'COGNITO_USER_POOLS',
providerArns: props.cognitoUserPools.map(userPool => userPool.userPoolArn),
authorizerResultTtlInSeconds: props.resultsCacheTtl?.toSeconds(),
identitySource: props.identitySource || 'method.request.header.Authorization',
identitySource: props.identitySource || IdentitySource.header('Authorization'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change caused by this is guaranteed by this test.

@@ -216,7 +218,7 @@ export class TokenAuthorizer extends LambdaAuthorizer {
authorizerUri: lambdaAuthorizerArn(props.handler),
authorizerCredentials: props.assumeRole?.roleArn,
authorizerResultTtlInSeconds: props.resultsCacheTtl?.toSeconds() ?? Duration.minutes(5).toSeconds(),
identitySource: props.identitySource || 'method.request.header.Authorization',
identitySource: props.identitySource || IdentitySource.header('Authorization'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change caused by this is guaranteed by this test.

* @see https://docs.aws.amazon.com/apigateway/api-reference/link-relation/authorizer-create/#identitySource
* this should be `method.request.header.Authorizer` where `Authorizer` is the header containing the bearer token.
*
* @see https://docs.aws.amazon.com/apigateway/latest/api/API_CreateAuthorizer.html#apigw-CreateAuthorizer-request-identitySource
* @default `IdentitySource.header('Authorization')`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value setting process has been changed to fit here.

* @see https://docs.aws.amazon.com/apigateway/api-reference/link-relation/authorizer-create/#identitySource
* this should be `method.request.header.Authorizer` where `Authorizer` is the header containing the bearer token.
*
* @see https://docs.aws.amazon.com/apigateway/latest/api/API_CreateAuthorizer.html#apigw-CreateAuthorizer-request-identitySource
* @default `IdentitySource.header('Authorization')`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value setting process has been changed to fit here.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 1, 2023
Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@aws-cdk-automation aws-cdk-automation added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Dec 1, 2023
Copy link
Contributor

mergify bot commented Dec 4, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Dec 4, 2023
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: af5b2fd
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 7208b8f into aws:main Dec 4, 2023
13 checks passed
Copy link
Contributor

mergify bot commented Dec 4, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@go-to-k go-to-k deleted the chore/apigateway-authorizer-id-source branch December 4, 2023 22:42
chenjane-dev pushed a commit to chenjane-dev/aws-cdk that referenced this pull request Dec 5, 2023
…ty source in authorizer (aws#28214)

Addressed the following points about Authorizer's `identitySource` property.

- Reference link is broken.
  - now: https://docs.aws.amazon.com/apigateway/api-reference/link-relation/authorizer-create/#identitySource
  - new: https://docs.aws.amazon.com/apigateway/latest/api/API_CreateAuthorizer.html#apigw-CreateAuthorizer-request-identitySource
- One explanation was confusing, so I enclosed it in quotes.
  - now: ```this should be `method.request.header.Authorizer` where Authorizer is the header containing the bearer token.```
  - new: ```this should be `method.request.header.Authorizer` where `Authorizer` is the header containing the bearer token.```
- Not using the static method written in the doc to set default values when a prop is not specified.
  - now: `'method.request.header.Authorization'`
  - new: `IdentitySource.header('Authorization')`

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 star-contributor [Pilot] contributed between 25-49 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants