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

Add support for custom identityPoolEndpoint #13445

Open
3 tasks done
madCodes opened this issue May 29, 2024 · 9 comments
Open
3 tasks done

Add support for custom identityPoolEndpoint #13445

madCodes opened this issue May 29, 2024 · 9 comments
Labels
Auth Related to Auth components/category feature-request Request a new feature

Comments

@madCodes
Copy link

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

Authentication

Amplify Version

v6

Amplify Categories

auth

Backend

Other

Environment information

# Put output below this line


Describe the bug

I have importing existing Cognito resource using amplify cli and set up authentication using react-ui package in nextjs. Everything runs smooth, but i need to change the domain which amplify cli uses for auth calls like fetchAuthSession. I have added custom domain to cognito using amazon web console and tried to pull cloud changes hoping to see "oauth": {"domain":"my-custom-domain.com"}. It never synced. I forcefully updated while setting Amplify.configure like below.

amplifyconfig.oauth.domain = "auth.mydomain.com";

Amplify.configure(amplifyconfig, {
  ssr: false,
});

No matter what i do, the amplify sdk always hit "cognito-identity.us-east-1.amazonaws.com" domain. Not sure, what am i missing here. Thanks.

Expected behavior

Hit my custom domain for all the amplify auth calls

Reproduction steps

Import existing cognito without custom domain i nto amplify.
Set the custom domain outside amplify, may be on aws web console.
Try configuring custom domain in the amplify

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@madCodes madCodes added the pending-triage Issue is pending triage label May 29, 2024
@cwomack cwomack self-assigned this May 30, 2024
@cwomack cwomack added the Auth Related to Auth components/category label May 30, 2024
@madCodes
Copy link
Author

@cwomack Were you able to reproduce this? Let me know if you need any further details. This is a show stopper for us as we need to run our app in a restricted environment where only my app domains are whitelisted and people are not able to login because amplify sdk hits *.amazonaws.com domains.

@cwomack cwomack added feature-request Request a new feature and removed pending-triage Issue is pending triage labels May 31, 2024
@cwomack
Copy link
Member

cwomack commented Jun 11, 2024

@madCodes, appreciate your patience with my response. While we support custom user pool endpoints, we do not currently provide any input for custom domains using identity pools with Amplify. We've marked this as a feature request and will review it internally.

@cwomack cwomack removed their assignment Jun 11, 2024
@cwomack
Copy link
Member

cwomack commented Jun 11, 2024

Following up on this further, @madCodes. Would using Custom User Pool endpoints work for your use case instead? I may have misunderstood the intent within this issue, but based on the related Discord thread I'm wondering if this Custom User Pool endpoints would work instead. These docs aren't very detailed, but the userPoolEndpoint docs may help here to see that it's an available option in the CognitoUserPoolConfig interface.

@cwomack cwomack self-assigned this Jun 11, 2024
@madCodes
Copy link
Author

madCodes commented Jun 18, 2024

@cwomack We are open to any solution which will avoid amplify auth hitting aws domains.If i understand correctly, i should pass "auth.mydomain.com" to userPoolEndpoint field? Sorry, but could you please help on how to pass this ? Currently i configure amplify as below.

import amplifyconfig from "@/amplifyconfiguration.json";
Amplify.configure(amplifyconfig);

Content of the amplifyconfiguration.json is as follows.

{ "aws_project_region": "us-east-1", "aws_cognito_region": "us-east-1", "aws_user_pools_id": "us-east-1_XXXXXX", "aws_user_pools_web_client_id": "1gc2XXXXXX", "oauth": { "domain": "auth.mydomain.com" }, "aws_cognito_username_attributes": ["EMAIL"], "aws_cognito_social_providers": [], "aws_cognito_signup_attributes": ["EMAIL"], "aws_cognito_mfa_configuration": "OFF", "aws_cognito_mfa_types": [], "aws_cognito_password_protection_settings": { "passwordPolicyMinLength": 8, "passwordPolicyCharacters": [] }, "aws_cognito_verification_mechanisms": ["EMAIL"] }

@israx
Copy link
Member

israx commented Jun 18, 2024

Hello @madCodes. Amplify makes API requests to both user-pool and identity-pool Cognito endpoints. Bellow I added more context for both.

  1. Override default user-pool endpoint, e.g. https://cognito-idp

You need to configure a custom endpoint via the Cognito console and configuring Amplify as follows:

Auth: {
    Cognito: {
      userPoolId: "xxxxxx",
      userPoolClientId: "xxxxx",
      identityPoolId: "xxxx",
      userPoolEndpoint:'endpoint', 
 }
}
  1. Override default identity-pool endpoint, e.g.
    https://cognito-identity

Unfortunately Amplify doesn't support overriding the default identity-pool endpoint

@Neuroforge
Copy link

Neuroforge commented Jul 19, 2024

This is so painful. I managed to get the signIn request working after upgrading from v5 -> v6 and then it failed when fetching the session. Is there any way to patch this?

Can anyone point me to the code where i can try and fix this? This is needed if we want to get the session data when working with something like LocalStack. (amplify-localstack isn't much better)

I am using this method to get the access/id tokens for Auth headers on API calls. Is there another way to get them for the logged in user so that they can make authenticated calls and refresh the tokens (if needed).

@jglee96
Copy link

jglee96 commented Jul 29, 2024

Could be related with #13025, #13552

@Neuroforge
Copy link

Could be related with #13552

Oh man! This is just sitting there. Are there any ways to get his moving forward?

#13552

@cwomack cwomack changed the title aws-amplify/auth fetchAuthSession makes network calls to https://cognito-identity.us-east-1.amazonaws.com/ even after setting up custom domain on cognito pool Add support for custom identityPoolEndpoint Aug 20, 2024
@cwomack
Copy link
Member

cwomack commented Aug 20, 2024

@Neuroforge, @jglee96, and @madCodes

Just wanted to ping you all to say that we are indeed tracking the PR for this feature in #13552 and that will be further reviewed/worked on once we get the bug resolved that is detailed within #13650.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auth Related to Auth components/category feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests

5 participants