-
Notifications
You must be signed in to change notification settings - Fork 249
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
feat(auth,api): cognito user pools auth provider & auth mode for API HTTP requests #1913
Conversation
@@ -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.'); |
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.
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.
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
packages/auth/amplify_auth_cognito_dart/lib/src/util/cognito_user_pools_auth_provider.dart
Outdated
Show resolved
Hide resolved
packages/auth/amplify_auth_cognito_dart/test/plugin/auth_providers_test.dart
Show resolved
Hide resolved
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.
Nice work! Looks like you have some failing tests, but otherwise looks good.
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.
Approved - please update the one test to be an integration test (using the state machine and plugin logic, and only mocking Cognito as needed).
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.