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

fix(appsync): erroneous api key created when additional authorization is not configured #9057

Merged
merged 4 commits into from
Jul 17, 2020

Conversation

matthias-pichler
Copy link
Contributor

@matthias-pichler matthias-pichler commented Jul 14, 2020

fixes #9054

The AppSync GraphQL API uses API_KEY Auth by default. For this it creates an API key. This is fine as long as API_KEY auth is configured for the API. But this behaviour is erroneous when API_KEY Auth is neither the default nor an addition authentication method.

This PR addresses this issue and ensures that an API key is only created when API_KEY auth is really configured.


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

Copy link
Contributor

@BryanPan342 BryanPan342 left a comment

Choose a reason for hiding this comment

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

Hi @warrify, thanks for contributing :)

Is it possible to write out a unit test for this to make sure that the API_KEY is not created?

Also, editing the commit message of the PR to explain the issue and approach at hand would be great for customers to be able to see.

@BryanPan342 BryanPan342 added the @aws-cdk/aws-appsync Related to AWS AppSync label Jul 15, 2020
@BryanPan342
Copy link
Contributor

@warrify

I wrote a unit test for it and posted it on gist here! Check it out and add to it if you want :)

As for the commit message, something that explains the issue and the fix should be sufficient:

AppSync creates unspecified ApiKey with empty additionalAuthorization. Changed implementation such that undefined additionAuthorizationModes doesn't product api key.

AppSync uses API Key Auth by default. If specifying another auth type it still creates a Key. Now a Key is only created if the auth mode or an additional auth mode is set to API_KEY.
@matthias-pichler
Copy link
Contributor Author

@BryanPan342 thanks for the test! Sorry for the delay, missed your first comment.

Copy link
Contributor

@BryanPan342 BryanPan342 left a comment

Choose a reason for hiding this comment

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

We have a picky linter :( makes me sad too but from the error logs

@aws-cdk/aws-appsync: 68:13 error Strings must use singlequote quotes
@aws-cdk/aws-appsync: 69:50 error Strings must use singlequote quotes
@aws-cdk/aws-appsync: 79:38 error Strings must use singlequote quotes

The change is simply to make these single quotes!

@BryanPan342
Copy link
Contributor

@BryanPan342 thanks for the test! Sorry for the delay, missed your first comment.

No worries @warrify! Thanks again for the contribution 😃 I think the only thing that's left is to update the PR description and address the linter 🎉

The linter expects single quotes and my Editor screwed them up
@BryanPan342 BryanPan342 changed the title fix(appsync): don't create API key if not needed fix(appsync): erroneous api key created when additional authorization is not configured Jul 17, 2020
@BryanPan342 BryanPan342 self-requested a review July 17, 2020 20:01
Copy link
Contributor

@BryanPan342 BryanPan342 left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

Nice job and thanks @warrify on the contribution 😃

@mergify
Copy link
Contributor

mergify bot commented Jul 17, 2020

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: daef092
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Contributor

mergify bot commented Jul 17, 2020

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

@mergify mergify bot merged commit 6f934e9 into aws:master Jul 17, 2020
@matthias-pichler matthias-pichler deleted the patch-1 branch July 20, 2020 15:35
curtiseppel pushed a commit to curtiseppel/aws-cdk that referenced this pull request Aug 11, 2020
… is not configured (aws#9057)

fixes aws#9054 

The AppSync GraphQL API uses API_KEY Auth by default. For this it creates an API key. This is fine as long as API_KEY auth is configured for the API. But this behaviour is erroneous when API_KEY Auth is neither the default nor an addition authentication method. 

This PR addresses this issue and ensures that an API key is only created when API_KEY auth is really configured.

----

*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
@aws-cdk/aws-appsync Related to AWS AppSync
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[aws-appsync] API always generates API key even when other default auth mode is set
4 participants