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(auth,api): cognito user pools auth provider & auth mode for API HTTP requests #1913

Merged
merged 5 commits into from
Aug 8, 2022
Merged

feat(auth,api): cognito user pools auth provider & auth mode for API HTTP requests #1913

merged 5 commits into from
Aug 8, 2022

Conversation

ragingsquirrel3
Copy link
Contributor

This PR enables cognito user pools auth mode in HTTP requests for API category, thus enabling REST and query/mutate in GraphQL. It does so by defining an auth provider in the auth plugin that provides the access token as a header to HTTP requests. In API plugin, that auth provider is used to authorize HTTP requests.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ragingsquirrel3 ragingsquirrel3 requested a review from a team as a code owner July 21, 2022 21:20
@@ -64,8 +64,15 @@ Future<http.BaseRequest> authorizeHttpRequest(http.BaseRequest request,
return authorizedRequest.httpRequest;
case APIAuthorizationType.function:
case APIAuthorizationType.oidc:
case APIAuthorizationType.userPools:
throw UnimplementedError('${authType.name} not implemented.');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I haven't tested with OIDC/lambda, but I'm thinking when we register the API auth providers from API plugin instantiation with the auth provider repo which define different way to get token, we can just remove this line here and this part should work with those providers.

@ragingsquirrel3 ragingsquirrel3 changed the title feat(auth,api): cognito user pools auth provider & auth mode for HTTP request (REST & GQL) feat(auth,api): cognito user pools auth provider & auth mode for API HTTP requests Jul 21, 2022
@codecov-commenter
Copy link

codecov-commenter commented Jul 21, 2022

Codecov Report

Merging #1913 (79ff3bc) into feat/api-next (7a98c5a) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@                Coverage Diff                @@
##           feat/api-next    #1913      +/-   ##
=================================================
+ Coverage          45.14%   45.17%   +0.02%     
=================================================
  Files                130      130              
  Lines               7713     7717       +4     
=================================================
+ Hits                3482     3486       +4     
  Misses              4231     4231              
Flag Coverage Δ
android-unit-tests ∅ <ø> (∅)
flutter-unit-tests 28.87% <100.00%> (+0.05%) ⬆️
ios-unit-tests 89.08% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...api/lib/src/decorators/authorize_http_request.dart 95.83% <100.00%> (+0.37%) ⬆️

Copy link
Contributor

@Equartey Equartey left a comment

Choose a reason for hiding this comment

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

Nice work! Looks like you have some failing tests, but otherwise looks good.

Copy link
Contributor

@dnys1 dnys1 left a comment

Choose a reason for hiding this comment

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

Approved - please update the one test to be an integration test (using the state machine and plugin logic, and only mocking Cognito as needed).

@ragingsquirrel3 ragingsquirrel3 merged commit c8297a6 into aws-amplify:feat/api-next Aug 8, 2022
@ragingsquirrel3 ragingsquirrel3 deleted the feat/api-cognito-auth-mode branch August 8, 2022 16:58
ragingsquirrel3 pushed a commit that referenced this pull request Aug 16, 2022
ragingsquirrel3 pushed a commit that referenced this pull request Aug 23, 2022
ragingsquirrel3 pushed a commit that referenced this pull request Sep 9, 2022
ragingsquirrel3 pushed a commit that referenced this pull request Sep 14, 2022
ragingsquirrel3 pushed a commit that referenced this pull request Sep 15, 2022
ragingsquirrel3 pushed a commit that referenced this pull request Sep 26, 2022
ragingsquirrel3 pushed a commit that referenced this pull request Oct 19, 2022
ragingsquirrel3 pushed a commit that referenced this pull request Nov 8, 2022
HuiSF pushed a commit to HuiSF/amplify-flutter that referenced this pull request Nov 10, 2022
ragingsquirrel3 pushed a commit that referenced this pull request Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants