-
Notifications
You must be signed in to change notification settings - Fork 1k
apigw certificate bound access token example added #2546
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
apigw certificate bound access token example added #2546
Conversation
|
@kbdraai I started testing this, but the Lambda Authorizer function fails with the following error: |
|
@ellisms Thanks for looking at this. Did you run a sam build with use_container=true? Can you elaborate on the process you followed? |
|
@kbdraai |
|
This looks like an issue with the token. To make it easier to get the token I used the AdminInitiateAuth Cognito API: You can also manually decode the token to ensure that it is correct. |
|
|
||
| 2. Change directory to the pattern directory: | ||
| ``` | ||
| cd apigw-certificate-bound-access-tokens |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| cd apigw-certificate-bound-access-tokens | |
| cd apigw-cognito-certificate-bound-access-token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filename needs to be Makefile otherwise make fails.
| cd apigw-certificate-bound-access-tokens | ||
| ``` | ||
|
|
||
| 3. Ensure that you add the relevant parameters to `samconfig.toml`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommend using sam deploy --guided instead of editing samconfig.toml manually.
| @@ -0,0 +1,89 @@ | |||
| # Certificate-Bound Access Tokens using API Gateway and Cognito | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # Certificate-Bound Access Tokens using API Gateway and Cognito | |
| # Certificate-Bound Access Tokens using Amaon API Gateway and Amazon Cognito |
|
|
||
| ## How it works | ||
|
|
||
| This pattern creates an Amazon API Gateway REST API as well as a custom domain name and enables mTLS. Further, it creates a Cognito User Pool. The Cognito User Pool is used to issue certificate-bound access tokens. The REST API makes use of an authorizer to compare the "cnf" claim in the access token to the fingerprint of the client certificate sent as part of the mutual authentication TLS handshake. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| This pattern creates an Amazon API Gateway REST API as well as a custom domain name and enables mTLS. Further, it creates a Cognito User Pool. The Cognito User Pool is used to issue certificate-bound access tokens. The REST API makes use of an authorizer to compare the "cnf" claim in the access token to the fingerprint of the client certificate sent as part of the mutual authentication TLS handshake. | |
| This pattern creates an Amazon API Gateway REST API with a custom domain name and enables mTLS. Further, it creates a Cognito User Pool. The Cognito User Pool is used to issue certificate-bound access tokens. The REST API makes use of an authorizer to compare the "cnf" claim in the access token to the fingerprint of the client certificate sent as part of the mutual authentication TLS handshake. |
|
|
||
| 4. Build the solution: | ||
| ``` | ||
| sam build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| sam build | |
| sam build --use-container |
|
|
||
| 1. Delete the stack | ||
| ```bash | ||
| aws cloudformation delete-stack --stack-name STACK_NAME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use sam delete since you are using SAM.
|
Thanks @kbdraai I was able to test this. Please review the requested changes and make the updates before we move forward. |
|
@ellisms ive updated README.md For the deploying the deploy command will be very bulky with all of the parameters which is why I opted for samconfig.toml. Let me know if this is still okay. I can make the change. I included the same code to get an access token using boto3. Let me know if this is fine as well. Otherwise I can add AWS CLI command. |
|
Typically the CLI is used, rather than creating language-specific code. Please update to use the CLI. For deploying, |
|
Changes pushed |
|
Thanks, adding this to the queue for publishing. |
Issue #, if available:
Description of changes:
Added certificate bound access token support using API Gateway and Cognito. Provided through a SAM template.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.