Reputation: 71
I'm having trouble with what should be a simple feature, but I can't figure out what guidelines to follow. I have a React web app and I want users to be able to do the following:
I know that you can do this by adding an IAM role manually through the AWS console, but I don't want users to have to do this. I want to be able to programmatically access their S3 buckets. I looked into using AWS Cognito, but as far as I can tell, that's for authenticating users and authorizing access to data that you own, not for the app to access buckets that the users own. Is there a way to do this? I'm just very lost after spending hours reading AWS guides and getting nowhere.
Upvotes: 0
Views: 1097
Reputation: 269320
There are two main ways for a 'user' to interact with AWS:
There is a 3rd option, which is to give each user a set of IAM User credentials, but this is rarely a good idea. It might be used where you have a limited set of users (eg a few close partner companies that regularly upload/download data), but certainly shouldn't be done with end-users of an application.
The most common scenario is #1, where users interact directly with your app. This lets you add features and potentially change cloud providers without impacting users. Your back-end can generate Amazon S3 pre-signed URLs, which provide time-limited access to private objects stored in Amazon S3. Your back-end is fully responsible for confirming that users are permitted to access these objects and for generating the pre-signed URLs.
If you really want to issue AWS credentials to the users (or their browser), then your back-end application should use the AWS Security Token Service (STS) to generate temporary credentials with the desired permissions. These credentials can then be used with standard AWS API calls to access AWS services such as Amazon S3, without going via your app. They will need to first authenticate to your back-end, which will generate the credentials for them. They will not use the AWS sign-in page, since they do not actually have any AWS credentials.
Amazon Cognito can provide several of these capabilities, such as authentication and automatic assumption of an IAM Role, providing back temporary credentials that can be used in the front-end.
Upvotes: 0