gpt4 book ai didi

amazon-web-services - AWS Cognito-使用Google登录时如何强制选择帐户

转载 作者:行者123 更新时间:2023-12-04 12:50:21 29 4
gpt4 key购买 nike

我目前正在使用与Google作为身份提供者联合的Cognito用户池来处理我的Web应用程序的用户登录。目前,我仅通过Google实现了登录。目前,这是通过Cognito的托管用户界面完成的。

当用户使用Google登录时,我希望始终提示他们选择他们的帐户,即显示this prompt

但是,我发现当我仅使用一个Google帐户登录时,将跳过此屏幕。虽然,当我没有登录任何Google帐户/2个或更多Google帐户时,都会显示此屏幕。

我试图使此屏幕始终显示的内容:

  • 使用AWS Amplify的federatedSignIn({provider: 'Google'})函数。但是,我发现这只是Cognito的Hosted UI上的包装,并且仅重定向到相同的授权端点,如here所述。
  • prompt=select_account添加到授权端点(如Google's documentation中所述),但这无效。这并不奇怪,因为AWS documentation for the authorization endpoint中未详细介绍prompt选项。

  • 如果有人对如何始终显示此帐户选择屏幕有任何想法,将不胜感激。

    最佳答案

    事实证明,此刻(2020年1月)(编辑:请参阅下面的建议解决方案,该解决方案仍然有问题)AWS Cognito不支持prompt=select_account(或Google提供的任何prompt选项)。在他们的支持下来回走了,这是他们当前的行动计划的最终结果:

    (restating the issue) Auth.signOut() only signs out from Cognito, but not from the federated provider (Google in your case). So when you try to login again (in your customers case, using Auth.federatedSignIn({ .provider: 'Google' })) it will automatically bypass Google's account selection/login and directly use the existing session. [which could be a problem if it is the wrong Google session]

    One sub optimal solution to this is to also sign out from Google. You can accomplish this by making a GET request to https://accounts.google.com/logout. This way, a subsequent federatedSignIn will need to go through the Google login screen.

    I have escalated this case to the Cognito service team in Seattle to get a feature request:

    Being able to pass a prompt="select_account" option via the URL query to Google.


    编辑以添加Cognito响应:

    If you're using Cognito Hosted UI, you can clean up the Cognito user pool session by invoking the following end point:

        https://<Your-User-Pool-Domain>.auth.<Your-User-Pool-Region>.amazoncognito.com/logout?client_id=<Your-User-Pool-App-Client>&logout_uri=<Your-User-Pool-SignOut-URL>

    When I (AWS Congito) tried to reproduce the issue with Cognito Hosted UI, I had to re-signIn Google after I signed out. I couldn't reproduce this issue one way or another.


    有关更多信息和各种选项,请参见 Cognito documentation for the logout link
    编辑以添加更多信息:不幸的是,此修复程序(使用注销链接)无法按预期工作。它确实允许用户选择一个新的身份提供者(Google,Facebook等),但是如果用户使用他们选择的身份提供者登录,则它将继续使用该用户身份,而不是让用户选择以下项:多个帐户或使用新帐户登录。

    关于amazon-web-services - AWS Cognito-使用Google登录时如何强制选择帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58154256/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com