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
cognitoUser.initiateAuth ignores the authentication flow setting #419
Comments
Hi @imjustdavid, there was a typo in our README.md user case 30. Now it is correct. Thanks!! |
Hi @yuntuowang, is it the same that lambda user migration can be triggered if I use aws-amplify Auth API ? It seems that it is default to be 'USER_SRP_AUTH'? |
Hi @Jun711, yes, the default flow type is 'USER_SRP_AUTH'. If you want to use the lambda user migration, you need to set flow type as 'USER_PASSWORD_AUTH'. |
thanks @yuntuowang |
Hi @Jun711, we already supported it in amplify library. Please see the use case 30 in the README.md and use the newest version of SDK(v1.32.0). |
@yuntuowang |
I see. Hi @mlabieniec, can you answer this question? @Jun711 wants to use the Auth from Amplify library instead of using amazon-cognito-identity-js within Amplify. |
@Jun711 are you using a framework i.e. React, Angular etc. Or similar? Or are you using vanilla javascript? If JavaScript, are you using ES2015+ with a transpiler i.e. Babel etc? Just trying to understand your environment so I can make the right recommendation. Generally, you can check here which will support any JavaScript environment via APIs. For React you can also use the HOCs. |
@mlabieniec I am using Angular to use migration trigger, it needs 'USER_PASSWORD_AUTH' flow type in authentication. However, this is not exposed via Auth, I think. What is the way around it? btw, @yuntuowang , how to import CognitoUser from amazon-cognito-identity-js within Amplify? Is it like the following? |
You can get the current user with Auth.currentAuthenticatedUser() method. I will look into exposing the password flow options as well here. |
I was trying to get the current user but I was trying to use amazon-cognito-identity-js within Amplify. Regarding the password, probably something like and use an argument to decide whether to set USER_PASSWORD_AUTH flow will work ?
If it works, lambda user migration should be invoked via Can I use only Amplify library with its dependencies and be able to use Amazon Cognito? (as in without using amazon-cognito-identity-js) |
Thanks a lot @yuntuowang. |
Hi @Jun711, you can import in this way: import { CognitoUser } from 'aws-amplify/node_modules/amazon-cognito-identity-js/lib/'; About the second question, yes. you can follow Use case 30 in README.md. |
thanks @yuntuowang |
Hi @Jun711, I think using amplify is better for your use case. Sure, you can post a PR and we can review it. Thanks! |
@yuntuowang I am trying to do a pul request.
And, there are 2 lock files. Should I run |
I'm a bit confused about the conclusion of this ticket. Is there any way to tell |
⬆️ on this issue, it doesn't currently seem possible to direct |
There is a solution now, at least: you can set the See https://aws-amplify.github.io/amplify-js/api/interfaces/authoptions.html |
Hi, Good day. Took me a while to figure this out. But I'm using angular and to set the flow I did the following in my app.component.ts:
Hope that helps somebody else out there. (who's a noob like me:) Regards. |
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Do you want to request a feature or report a bug?
Potential bug
What is the current behavior?
The function cognitoUser.initiateAuth() ignores the authentication flow setting. It always sends a request specifying a CUSTOM_AUTH flow. When used to implement a lamba user migration trigger as specified in https://docs.aws.amazon.com/cognito/latest/developerguide/using-amazon-cognito-javascript-sdk-user-migration-lambda.html, it causes the lambda user migration not to be invoked, since Cognito is expecting a USER_PASSWORD_AUTH authentication flow.
This can be circumvented by using cognitoUser.authenticateUser() instead, that configures the request considering the authentication flow setting
The text was updated successfully, but these errors were encountered: