javascript - 按自定义属性搜索亚马逊 Cognito 用户

标签 javascript react-native amazon-cognito aws-amplify

我正在开发一个 react native 应用程序,它使用 aws-amplify 与 amazon cognito 进行交互。在我的用例中,我需要确保自定义属性的值在所有帐户中都是唯一的。 aws-amplify 似乎没有允许我通过自定义属性搜索所有帐户的 API。我怎样才能做到这一点?

最佳答案

不幸的是,您无法单独使用 Cognito:

https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-manage-user-accounts.html#cognito-user-pools-searching-for-users-using-listusers-api

Custom attributes are not searchable. This is because only indexed attributes are searchable, and custom attributes cannot be indexed.

您唯一的选择是保留您自己的数据库,将用户与属性值相关联,并在其中强制执行唯一性。例如,在 DynamoDB 中,您将记录用户的 sub(唯一的 Cognito 身份)和自定义属性的值作为相应的排序/分区键,确保普通的 Cognito 客户端只能读取 自定义属性,并提供您自己的 API(lambda + api-gateway)以尝试添加/更新表并使用 cognito Admin API 更新用户的“只读”自定义属性。

关于javascript - 按自定义属性搜索亚马逊 Cognito 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53293080/

相关文章:

javascript - 根据 API 的结果嵌入 YouTube 视频

javascript - 使用 Google oAuth 2.0 时刷新新用户登录页面

ios - facebook SDK react native : no framework search path

android - React Native - 在 Android 上集成棕地

ios - 按角色过滤 AWS-Cognito 用户

ios - 如何将用户添加到 AWS Cognito 用户池组?

php - Javascript PHP N 层架构

javascript - 你如何监听 javascript 中的多个字段更改?

javascript - 无法从 Indeed 找到模块 `./index`

amazon-web-services - 使用授权者后出现 AWS Amplify API Gateway cors 错误 : aws_iam