2

我正在尝试将应用程序负载均衡器连接到 AWS Cognito,除了尝试保存更改并收到此错误“用户池客户端必须具有客户端密码”外,一切似乎都正确,我用谷歌搜索但没有找到任何有用的东西。

我能够成功测试 Cognito 身份验证 UI(我认为...),所以我不明白 AWS 为什么会抱怨用户池客户端。

所以问题是,有没有人遇到过这个问题,如果你遇到过,你是怎么解决的?

编辑:

基本上,我所做的一方面是我将 Cognito 配置为仅与 Google OAuth 一起使用(我删除了亚马逊默认的 OAuth),另一方面我创建了一个具有多个规则的应用程序负载均衡器,每个规则指向一个不同的目标group,每个目标组是一个运行在 Kubernetes 上的 Docker 应用程序。(又名 EKS)。所有这些应用程序都有不同类型的身份验证,或者根本没有。所以想法是在 ALB 中添加一个规则来使用 Cognito 对用户进行身份验证。问题是,在添加了所有必需的参数之后,就在我要保存我的更改时,所有这些新的更改。我收到一个错误“用户池客户端必须有一个客户端密码”,我用谷歌搜索了那个确切的句子,除了我在其他地方发布的帖子外,我什么也没得到。

谢谢你的时间!

4

2 回答 2

2

您在 Cognito 中创建的应用程序客户端需要应用程序客户端密码。您不能将应用程序客户端密码添加到现有应用程序客户端,但您可以简单地创建一个新的,然后勾选生成密码框(默认情况下)。

这是必需的,因为它是 Cognito 和 ALB 集成实施的 Oauth 标准的额外安全级别。在通过 Cognito 进行身份验证后返回给 ALB 的“授权码”将由 ALB 交换给 Cognito 以获得令牌。此交换将需要秘密,并且由于 ALB 是唯一知道秘密的应用程序,因此它使这更加安全。

于 2020-01-20T22:20:44.853 回答
0

为了使 AWS Cognito 正常工作,您需要一些基本配置。请参阅 Amplify 的代码摘录(适用于 Cognito 的 AWS 开发库)。

import Amplify, { Auth } from 'aws-amplify';

Amplify.configure({
    Auth: {

        // REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID
        identityPoolId: 'XX-XXXX-X:XXXXXXXX-XXXX-1234-abcd-1234567890ab',

        // REQUIRED - Amazon Cognito Region
        region: 'XX-XXXX-X',

        // OPTIONAL - Amazon Cognito Federated Identity Pool Region 
        // Required only if it's different from Amazon Cognito Region
        identityPoolRegion: 'XX-XXXX-X',

        // OPTIONAL - Amazon Cognito User Pool ID
        userPoolId: 'XX-XXXX-X_abcd1234',

        // OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)
        userPoolWebClientId: 'a1b2c3d4e5f6g7h8i9j0k1l2m3',

        // OPTIONAL - Enforce user authentication prior to accessing AWS resources or not
        mandatorySignIn: false,

        // OPTIONAL - Configuration for cookie storage
        // Note: if the secure flag is set to true, then the cookie transmission requires a secure protocol
        cookieStorage: {
        // REQUIRED - Cookie domain (only required if cookieStorage is provided)
            domain: '.yourdomain.com',
        // OPTIONAL - Cookie path
            path: '/',
        // OPTIONAL - Cookie expiration in days
            expires: 365,
        // OPTIONAL - Cookie secure flag
        // Either true or false, indicating if the cookie transmission requires a secure protocol (https).
            secure: true
        },

        // OPTIONAL - customized storage object
        storage: new MyStorage(),

        // OPTIONAL - Manually set the authentication flow type. Default is 'USER_SRP_AUTH'
        authenticationFlowType: 'USER_PASSWORD_AUTH'
    }
});

// You can get the current config object
const currentConfig = Auth.configure();
于 2019-10-29T06:32:23.247 回答