使用确认URL确认Amazon Cognito后如何重定向? [英] How to redirect after confirm amazon cognito using confirmation URL?
问题描述
在用户以Amazon Cognito确认后,我想重定向到特定的网址。
I want to redirect to a specific url after the user confirmation in amazon cognito.
注册用户时,他将收到带有验证链接的确认邮件,如下所示
https://<> .auth.us-west-2.amazoncognito.com / confirmUser?client_id =<< >>& user_name =<< >>& confirmation_code =<< >>
When a user sign up he will get confirmation mail with a verification link as follows https://<>.auth.us-west-2.amazoncognito.com/confirmUser?client_id=<<>>&user_name=<<>>&confirmation_code=<<>>
如果用户单击
一旦用户确认完成,该页面应重定向到我的应用程序。
Once the user confirmation is completed the page should redirect to my application.
请给我一些解决此问题的想法。
Please give me some idea to solve this problem.
推荐答案
目前,无法使用电子邮件中的验证链接来完成此重定向。我曾尝试过将redirect_uri添加到验证URL上,但它们无法正常工作。
Currently, this redirection can't be done using verification link in email. I tried adding redirect_uri to the verification URL a while back but they do not work.
解决方法
- 在Api网关中创建一个API,该API接受这3个参数和一个额外的redirect_uri参数。在后端Lambda中,使用参数&向实际链接发出GET请求。确认用户。成功后,使用redirect_uri作为参数从您的API返回302重定向。
- 在您的用户池中,使用自定义消息触发器来建立指向您的API网关api的链接,而不是默认的cognito url
- 因此,验证链接应类似于: https://myapi.abc.com/confirm?client_id=somevalue&user_name=some_user&confirmation_code=some_code&redirect_uri=https://myapp.com
-
这些值将传递到后端lambda,后者向 https://your_domain.auth.us-west-2.amazoncognito.com/confirmUser?client_id=somevalue&user_name=some_user& ; confirmation_code = some_code
成功后,返回302 https://myapp.com 从您的API网关
On success, return 302 https://myapp.com from your API Gateway
我知道这是解决这种简单要求的复杂方法。最好的方法是提出功能请求,并希望它们在Cognito URL中支持redirect_uri。
I know this is a convoluted workaround for such a simple requirement. The best way would be to raise a feature request and hope they support a redirect_uri in the Cognito URL.
EDIT
要节省Lambda成本,您还可以在API中使用HTTP终结点,并向您所在地区的认知服务端点。示例:
To save your lambda costs, you could also use an HTTP endpoint in your API and make a request to the cognito service endpoint for your region. Example:
POST HTTP/1.1
Host: cognito-idp.us-east-1.amazonaws.com
x-amz-target: AWSCognitoIdentityProviderService.ConfirmSignUp
Content-Type: application/x-amz-json-1.1
{
"ClientId":"xxxxxxxxxxxxx",
"ConfirmationCode":"123456",
"Username":"username"
}
这篇关于使用确认URL确认Amazon Cognito后如何重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!