简体   繁体   English

如何避免在Cognito Federated Identities中创建未使用的身份

[英]How to avoid creating unused identities in Cognito Federated Identities

Every time I run the aws:aws-sdk-ios-samples/CognitoSync-Sample it generates a new unique IdentityId for my device. 每次运行aws时:aws-sdk-ios-samples / CognitoSync-Sample都会为我的设备生成一个新的唯一IdentityId。 If I shut down the app and restart it it gets the same IdentityId (from the keychain). 如果我关闭应用程序并重新启动它,它将获得相同的IdentityId(来自钥匙串)。 But if I log in with google, and log out it does a AWSCognito.defaultCognito().wipe() - and the wipe function clears the keychain. 但是,如果我使用谷歌登录,并注销它会执行AWSCognito.defaultCognito()。擦除() - 并且擦除功能会清除钥匙串。

Then if I restart the app, I get a new unique IdentityId. 然后,如果我重新启动应用程序,我会得到一个新的唯一IdentityId。

The first time I log in with a google or facebook identity it uses that newly created IdentityId as the authenticated IdentityId. 我第一次使用google或facebook身份登录时,会使用新创建的IdentityId作为经过身份验证的IdentityId。 But after that first login, whenever i start the app, I get a new ID, which then gets thrown away when I log in and get the (now permanent) facebook or google id. 但是在第一次登录后,每当我启动应用程序时,我都会获得一个新ID,然后当我登录并获得(现在是永久性的)facebook或google id时,它会被丢弃。

Am I supposed to write some "Identity Id Cleanup" function to go and sweep up all these old ids? 我是否应该编写一些“身份识别清理”功能来清除所有这些旧ID? How am I supposed to limit the number of Ids? 我该如何限制Ids的数量? (every time a user starts my app and logs in he will throw away a new unauthenticated ID... floating forever in Cognito Land). (每当用户启动我的应用程序并登录时,他将丢弃一个新的未经身份验证的ID ...永远漂浮在Cognito Land中)。

I edited the AWSCognito.defaultCognito().wipe() method in AWSCognitoService.m and removed the keychain clear, but that didn't help because the keychain after logout contains the authenticated identityId from the google login. 我在AWSCognitoService.m中编辑了AWSCognito.defaultCognito()。wipe()方法并删除了明确的钥匙串,但这没有帮助,因为注销后的钥匙串包含来自google登录的经过身份验证的identityId。

I think the Unauthenticated users are not really well thought out. 我认为Unauthenticated用户并没有经过深思熟虑。 Just during testing with 3 Id's I generate about a dozen id's a day, they are marked as disabled in the identity pool. 就在使用3 Id进行测试期间,我每天生成大约十二个id,它们在身份池中被标记为禁用。

How do I clean them up? 我该如何清理它们? Or how do I stop producing them? 或者我该如何停止生产?

or am i supposed to remember my own unauthenticated ids, and try to reconnect with them somehow (if so how?) 或者我应该记住我自己未经验证的ID,并尝试以某种方式与它们重新连接(如果是这样的话?)

It seems you do not want to support the 'Guest user' or 'Unauthenticated user' use case in your app. 您似乎不希望在应用中支持“访客用户”或“未经身份验证的用户”用例。 If this is correct, you can just disable "Unauthenticated Identities support" for your identity pool. 如果这是正确的,您可以为您的身份池禁用“未经身份验证的身份支持”。 Your users will always have to login with some provider before federating in this case and undesired unauthenticated identities will not be generated. 在这种情况下联合之前,您的用户将始终必须使用某些提供程序登录,并且不会生成不需要的未经身份验证的身份。

If you do want to support unauthenticated identities on a device, you should not wipe the data from device storage. 如果您确实希望在设备上支持未经身份验证的身份,则不应从设备存储中擦除数据。 If you do not wipe, the SDK will make sure it uses the cached identity id and will not generate a new one. 如果您不擦除,SDK将确保它使用缓存的身份标识,并且不会生成新标识。 Unlike authenticated identities, unauthenticated identities are by design only accessible if you know the identity id. 与经过身份验证的身份不同,未经身份验证的身份仅在您知道身份ID时才可访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM