In the last post, we discussed the concepts behind the valet key pattern. In this post, I will walk through how to perform this operation on AWS.
In AWS, in general, all bucket access is controlled by IAM. AWS also has the concept of signed urls, which allow someone to share a URL (very similar to SAS tokens in Azure). We will look at both techniques in this post.
Temporary tokens can be issued from the AWS Security Token Service and function much the same way as the access keys to any IAM role. The difference is that they can be used for temporary access.
In Powershell, you can use the Use-STSRole command to generate a temporary token.
Here is an example:
$credential = Use-STSRole -RoleArn <<arn>> -DurationInSeconds 900 -region ca-central-1 -roleSessionName <<name>>
Basically, your web application principal will need to have permissions to assume an appropriate role. You will likely want to create a specific role with permissions (eg: read, update, delete) to target buckets. The above command can then be run to assume that role for a duration of 900 seconds.
The last parameter above, roleSessionName, allows you to alias a particular session and keep track of the credentials you have given out.
A couple of notes:
Pre-signed URLs can be created via the API. For powershell, the cmdlet you are looking for is Get-S3PreSignedURL. When you create a per-signed URL, there a multitude of options you can set on the key itself. A couple of interesting ones:
Expire - The expiry time for the token
Protocol - The protocol allowed to be used
Verb - The HTTP verbs that the key will authorize for
Here is an example of what the key looks like.
The above key makes use of the AWS Signature Version 4. You can find out more information on the various settings by going to https://docs.aws.amazon.com/AmazonS3/latest/API/sig-v4-authenticating-requests.html
I think of the two methods described above, the Pre-signed URLs are most likely the best choice to satisfy the valet key pattern.
Shamir is a Microsoft Most Valuable Professional (MVP – Azure) and has extensive experience building solutions in the cloud, from strategy to deployment to automation