Amazon Cognito - OpenID Connect - 无效+提供商名称/用户名+组合

Ana*_*iya 9 amazon-web-services amazon-cognito aws-amplify-sdk-js

我正在尝试在我的 Cognito 用户池中配置 Microsoft Azure AD B2C身份提供商。

我在前端使用https://www.npmjs.com/package/@aws-amplify/auth库。

我已经命名了新的身份提供者Microsoft。我还在我的用户池中启用了它。我将相同的 ( Microsoft) 传递给该Auth.federatedSignIn方法。

现在,当我尝试通过 Microsoft 对用户进行身份验证时,用户会从 Microsoft 方面进行身份验证,但 Cognito 会向我显示错误?error_description=Invalid+ProviderName/Username+combination.+Please+check+again+&state=XmnGedOhmT99RnTlw0LypyMmqwCRbCZr&error=invalid_request

这对我来说似乎是一个配置问题,但我无法弄清楚它是什么。

请帮忙。

Dra*_*ski 4

一段时间后,我们设法解决了这个问题。问题是用户与 ProviderAttributeValue链接为小写,但在 OIDC 提供商的子声明中存在大写字母,这就是整个混乱的根源。如果用户与子声明提供的原始值链接,则一切正常

https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminLinkProviderForUser.html

{
   "DestinationUser": { 
      "ProviderAttributeName": "string",
      "ProviderAttributeValue": "string",
      "ProviderName": "string"
   },
   "SourceUser": { 
      "ProviderAttributeName": "string",
      "ProviderAttributeValue": "string" //ensure that value is same as in sub claim,
      "ProviderName": "string"
   },
   "UserPoolId": "string"
}
Run Code Online (Sandbox Code Playgroud)

要访问预注册 lambda 等中的原始子声明,您应该将子声明从 OIDC 提供程序映射到自定义属性,即custom:sub。应用程序客户端还必须具有自定义属性的读写权限,才能使其显示在 lambda 事件用户属性中event.request.userAttributes['custom:sub']