-
Notifications
You must be signed in to change notification settings - Fork 824
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
Custom domain support with Cognito #1880
Comments
@venkatesh-kadiyala CLI doesn't have custom domain support as of yet. How did you update your user-pool with your custom domain? |
@venkatesh-kadiyala How have you modified your |
@kaustavghosh06 // WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten. const awsmobile = { export default awsmobile; |
Vote +1 for feature implementation |
Vote +1, critical feature for any production app, otherwise would be frown upon by customers if they see Amazon Cognito as domain when clicking google/facebook login |
+1 am currently facing the same issue - overwriting the domain in aws-exports when running Amplify.configure() on my react-app based on the environment thats deployed |
Any update on this one? What is the best work around for this at the moment? BR, |
I worked around this by adding something like this: import config from "./aws-exports";
// Update Cognito Settings
config.oauth.domain = "staging.auth.xxxxx.app";
Amplify.configure(config); |
Is there a way to convince amplify of an updated auth domain? It reverts to my old domain any time I |
I use @kylekirkby's workaround setting the domain from an environment variable and it's working great. |
As @devth said it seems to revert even with amplify pull / push, so the best for now is to override. |
I ran into this issue by accidentally updating the domain settings in the Cognito UI - unaware it wasn't supported. My {
...,
"oauth: {},
...
} The env override method didn't work for me, but the following did (Note: this method does not support fully custom domains either). $ amplify update auth
Please note that certain attributes may not be overwritten if you choose to use defaults settings.
You have configured resources that might depend on this Cognito resource. Updating this Cognito resource could have unintended side effects.
Using service: Cognito, provided by: awscloudformation
What do you want to do? Apply default configuration with Social Provider (Federation)
What domain name prefix do you want to use? my-custom-cognito-domain
Enter your redirect signin URI: <redirect uri>
? Do you want to add another redirect signin URI No
Enter your redirect signout URI: <redirect signout uri>
? Do you want to add another redirect signout URI No
...
$ amplify push You will now get {
...,
"oauth": {
"domain": "my-custom-cognito-domain-<Amplify ENV>.auth.<Amplify Region>.amazoncognito.com",
"scope": [
"phone",
"email",
"openid",
"profile",
"aws.cognito.signin.user.admin"
],
"redirectSignIn": ...,
"redirectSignOut": ...,
"responseType": "code"
},
...
} This was able to unblock my development, but its a bandaid solution for sure. Hopefully we can get custom domain support soon. |
While Amplify doesn't have support for this yet, the customization that Amplify provides is enough to automate the configuration of the backend resources. I wrote an article about how the configuration can be done to hopefully saves some others time: https://medium.com/@matt.lavin/automating-cognito-custom-auth-domains-with-amplify-33e7b8f13266 |
I also use @kylekirkby's workaround. These are the lines which set amplify-cli/packages/amplify-frontend-javascript/lib/frontend-config-creator.js Lines 250 to 252 in 525deb6
At this stage, we can't tell if HostedUIDomain is a custom domain or not.So we need to add HostedUICustomDomain: userPool.CustomDomain in amplify-category-auth.
|
HostedUIDomain equals to either the domain prefix or the custom domain defined in the user pool. However we need to differentiate a custom domain from a domain prefix for the config put in aws-exports.js fix aws-amplify#1880
Building upon kylekirkby answer: I did this: import awsConfig from './aws-exports';
const updatedAwsConfig = {
...awsConfig,
oauth: {
...awsConfig.oauth,
domain: "auth.mycustomdomain.com",
redirectSignIn: "https://" + location.hostname + "/singin/redirect/path/",
redirectSignOut: "https://" + location.hostname + "/signout/redirect/path/"
}
}
Amplify.configure(updatedAwsConfig); Every redirect route must be configured with Amplify. The custom domain must be authorized in Route 53. This works even if you have multiple websites (dev1, dev2, dev3 ) to redirect to: and amazon only redirects to the correct server. (answering the original question of venkatesh-kadiyala (OP). |
It looks like adding a custom domain to the Cognito user pool causes
Anyone else experiencing this? |
@UnicornAccount this is simple and clear. Just wandering why Amplify docs have not included it? |
I'm guessing this isn't supported yet because authorizing SES from sandbox isn't straightforward. |
Any updates on this? It's been 3 years |
HostedUIDomain equals to either the domain prefix or the custom domain defined in the user pool. However we need to differentiate a custom domain from a domain prefix for the config put in aws-exports.js fix aws-amplify#1880
HostedUIDomain equals to either the domain prefix or the custom domain defined in the user pool. However we need to differentiate a custom domain from a domain prefix for the config put in aws-exports.js fix aws-amplify#1880
HostedUIDomain equals to either the domain prefix or the custom domain defined in the user pool. However we need to differentiate a custom domain from a domain prefix for the config put in aws-exports.js fix aws-amplify#1880
+1! |
1 similar comment
+1! |
Updates?? |
Our users are confused by the generic cognito endpoint being prompted when SSO is utilized, would be ideal to white label these, while it is is possible to do manually from the Cognito console, it is not really compatible with the CLI. |
Hi @maziarzamani , u can explain how to do it in Cognito console? I don't find anything about how to configure it |
👀 |
I'm facing this issue. There is no way to update my custom domain in aws-export.js file. |
There's a very simple workaround solution ....
|
Sorry, but, i don't understand your workaround. This piece of code is required to work the feat. The problem is on the custom provider login screen, because it says "continue to cognito..." where it should say "continue to my application name..." |
Can you show a screenshot |
Not an amplify issue (or related to this issue). Update your Google Console domains. Edit - once your custom domains are verified, delete any cognito domains from Google Console. Remember you need to update it for the callback as well |
Ohh, thank you so much! |
Is there an ETA for this? Any updates? |
This simple solution worked for me in my vue 3 application. The key is updating the value of awsExports.oauth.domain prior to passing that to Amplify.configure.
|
Hi @k2-tek, I'm having trouble understanding the solution provided. Since my custom domain doesn't consist of a user-friendly string, I would prefer using something like "My App" instead of the current format "my-app-example-cognito." Can you please clarify or suggest an alternative approach? |
If you setup your own custom domain in AWS Cognito then this should solve your issue. You can follow the AWS documentation below. https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-add-custom-domain.html |
This worked for me! |
@osehmathias can you clarify what you mean by updating the callbacks as well? I have it working as specified in the docs with Thanks! |
Describe the bug
We configured custom domain for cognito hosted UI and when user tries to login it calls both cognito domain (ending up with invalid_grant error) and to custom domain (success response) and sometimes it fails for both of them. When I run "amplify status" it gives Hosted UI endpoints with cognito domain. I tried to update the domain name using "amplify update auth" and it doesn't allow me to update custom domain name. I tried to override auth configurations in my App.js file with custom domain but somehow it still calls both cognito domain and custom domain.
**Screenshots
**
You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app.
The text was updated successfully, but these errors were encountered: