简体   繁体   English

如何找出上传到 s3 的用户的 Cognito 用户名?

[英]How to find out the Cognito username of a user uploading to s3?

I have a web application that uses aws-amplify storage to allow users to upload files to S3.我有一个 web 应用程序,它使用 aws-amplify 存储允许用户将文件上传到 S3。 (The files are later processed by a lambda.) The application uses Cognito for authentication and for authorizing these uploads. (这些文件稍后由 lambda 处理。)该应用程序使用 Cognito 进行身份验证和授权这些上传。

I need to know the Cognito username of the users for subsequent processing of the file.我需要知道用户的 Cognito 用户名,以便后续处理文件。 However, the Owners field of the file shows me an IAM group rather than the Cognito identification of the user.但是,文件的Owners字段向我显示了一个 IAM 组,而不是用户的 Cognito 标识。 (I think that's because of the federated identity service that's being used) (我认为这是因为使用了联合身份服务)

Is there any way of finding out the Cognito username of the user who uploaded the file?有没有办法找出上传文件的用户的 Cognito 用户名? One way I can think of is adding the username as metadata during the file upload, but that doesn't seem like a secure way to do it, because a user could potentially modify the javascript code to remove/modify that data.我能想到的一种方法是在文件上传期间将用户名添加为元数据,但这似乎不是一种安全的方法,因为用户可能会修改 javascript 代码以删除/修改该数据。

I don't have much experience with AWS.我对 AWS 没有太多经验。 Apologies if I'm missing something obvious.抱歉,如果我遗漏了一些明显的东西。

You can use GetUser API call to get this information.您可以使用GetUser API 调用来获取此信息。 I find this is helpful while you try to get the relevant information for the user as well.当您尝试为用户获取相关信息时,我发现很有帮助。

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

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