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(auth): custom userPoolEndpoint cannot be applied on the server-side #13739

Merged
merged 15 commits into from
Sep 10, 2024

Conversation

HuiSF
Copy link
Member

@HuiSF HuiSF commented Aug 20, 2024

Description of changes

This PR re-organized the Cognito Identity service clients, and turn them into factory function. These factories expecting an endpointResolver to be injected as dependency. So they can be created within the Auth category API calls, and ensure it uses the always up-to-date endpoint information.

Issue #, if available

#13650

Description of how you validated changes

  • Updated and added unit tests
  • Manual testing calling the Auth category APIs and verify a custom user pool endpoint is applied

Checklist

  • PR description included
  • yarn test passes
  • Unit Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

Checklist for repo maintainers

  • Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
  • New source file paths included in this PR have been added to CODEOWNERS, if appropriate

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

Copy link

⚠️ This PR includes changes to the "aws-amplify" package.json file, which can have library-wide implications.

Please ensure that this PR:

  • Does not manually change "@aws-amplify/*" dependency versions, which may misalign core dependencies across the library
  • Remove any export paths without a major version bump

A repository administrator is required to review this change.

packages/auth/src/foundation/core/parsers/getRegion.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

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

General question - how do we feel about index files? I think I still like them for selectively exposing functions from a group (subpath/folder)

Copy link
Member Author

Choose a reason for hiding this comment

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

It shortens import path on some occasions which is a nice way to organize code.
Though need to be care full import unexpected side effect?

e.g.

index.ts 
  module1.ts // <- has a side effect executes on module loads
  module2.ts

I want to use a function provided from module2, if import from index.ts, the side effect lives in module1 may get attached.

Copy link
Member

Choose a reason for hiding this comment

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

Seems like a good reason to consider dropping the practice overall except for maybe exposing types and controlling top level exports 🤔

@@ -0,0 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Seems like a good reason to consider dropping the practice overall except for maybe exposing types and controlling top level exports 🤔

import { cognitoUserPoolEndpointResolver } from '../../../foundation/cognitoUserPoolEndpointResolver';

export const createCognitoUserPoolEndpointResolver =
({ endpointOverride }: { endpointOverride: string | undefined }) =>
Copy link
Member

Choose a reason for hiding this comment

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

why not just making the endpointOverride key optional instead of forcing to pass a value?

Copy link
Member Author

Choose a reason for hiding this comment

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

See this comment, it answers this.

cshfang
cshfang previously approved these changes Aug 22, 2024
israx
israx previously approved these changes Aug 23, 2024
AllanZhengYP
AllanZhengYP previously approved these changes Aug 23, 2024
ashika112
ashika112 previously approved these changes Aug 24, 2024
@HuiSF HuiSF dismissed stale reviews from ashika112, israx, AllanZhengYP, and cshfang via d13d507 September 4, 2024 23:12
@@ -27,12 +27,12 @@ import { assertValidationError } from '../../../errors/utils/assertValidationErr
import { AuthValidationErrorCode } from '../../../errors/types/validation';
import { AuthErrorCodes } from '../../../common/AuthErrorStrings';
import { cacheCognitoTokens } from '../tokenProvider/cacheTokens';
import { tokenOrchestrator } from '../tokenProvider';
Copy link
Member

Choose a reason for hiding this comment

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

nit: unused?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm pretty sure it's used at line 98

@HuiSF HuiSF merged commit a76b594 into main Sep 10, 2024
30 checks passed
@HuiSF HuiSF deleted the hui/fix/auth/endpoint-resolver branch September 10, 2024 21:59
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.

6 participants