将用户从一个 AWS Cognito 池迁移到另一个保持 CognitoId/Sub 值 [英] Migrating Users from one AWS Cognito Pool to another keeping the CognitoId/Sub value

查看:19
本文介绍了将用户从一个 AWS Cognito 池迁移到另一个保持 CognitoId/Sub 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近发布的 AWS Cognito 现在允许用户名输入不区分大小写,但是您无法在当前用户池上启用它,并且需要创建一个新的用户池,然后将用户迁移到它...

A recent-ish release of AWS Cognito has now allowed for case insensitivity for username input however you can't enable it on a current User Pool and requires to create a new User Pool and then migrate the users to it...

因此,我创建了一个新的用户池,并且迁移 lambda 成功运行,但我遇到了最后一个问题.我们在其他系统中使用 CognitoId 作为主键,现在当我从 UserPool A 迁移到 UserPool B 时,它会创建一个新的 CognitoId 并且似乎不可能(从我所见)手动设置 CognitoId/Sub 作为新池中前一个池的值.

So, I've created a new user pool and have a Migration lambda working successfully but I've hit one final issue. We use the CognitoId as a Primary Key within our other systems and now when I migrate the from UserPool A to UserPool B, it creates a new CognitoId and it doesn't seem possible (from what I can see) to manually set the CognitoId / Sub as the value from the previous pool in the new pool.

以前有没有人遇到过这个问题并有解决办法,因为更新对新密钥的所有引用并不容易.(新的 CognitoId 也不会返回给过程中的任何函数)

Has anyone come across this before and have a work around as it's not easily feasible to update all references to a new key. (The new CognitoId isn't returned to any function in the process either)

推荐答案

Cognito Sub 在创建用户时由服务在内部生成.它是不可变的,不能分配新值.从旧用户池存储子"的一种方法可能是将其存储在 自定义属性 新用户池.您可以检查 ID 令牌中的自定义属性声明,以从现有系统访问用户数据.

Cognito Sub is generated internally by the service when the user is created. It is immutable and cannot be assigned a new value. One approach to store "sub" from the old userpool could be to store it in a custom attribute of new userpool. You can check for the custom attribute claim in the ID token to access the user data from your existing system.

自定义属性仅在 Cognito ID 令牌.如果您目前正在将 Cognito 访问令牌用于其他系统,则此方法对您不起作用.

Custom attribute is only available in Cognito ID token. If you are currently using Cognito access token with your other systems, this approach won't work for you.

这篇关于将用户从一个 AWS Cognito 池迁移到另一个保持 CognitoId/Sub 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆