简体   繁体   中英

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. (The files are later processed by a lambda.) The application uses Cognito for authentication and for authorizing these uploads.

I need to know the Cognito username of the users for subsequent processing of the file. However, the Owners field of the file shows me an IAM group rather than the Cognito identification of the user. (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? 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.

I don't have much experience with AWS. Apologies if I'm missing something obvious.

You can use GetUser API call to get this information. I find this is helpful while you try to get the relevant information for the user as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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