My AS3 Bucket Policy only applies to some Objects

后端 未结 1 1244
既然无缘
既然无缘 2021-01-27 09:25

I\'m having a really hard time setting up my bucket policy, it looks like my bucket policy only applies to some objects in my bucket.

What I want is pretty simple: I sto

1条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-27 10:00

    Controlling access via aws:Referer is not secure. It can be overcome quite easily. A simple web search will provide many tools that can accomplish this.

    The more secure method would be:

    • Keep all objects in your Amazon S3 bucket private (do not "Make Public")
    • Do not use a Bucket Policy
    • Users should authenticate to your application
    • When a user wishes to access one of the videos, or when your application creates an HTML page that refers/embeds a video, the application should determine whether the user is entitled to access the object.
    • If the user is entitled to access the object, the application creates an Amazon S3 pre-signed URL, which provides time-limited access to a private object.
    • When the user's browser requests to retrieve the object via the pre-signed URL, Amazon S3 will verify the contents of the URL. If the URL is valid and the time limit has not expired, Amazon S3 will return the object (eg the video). If the time has expired, the contents will not be provided.

    The pre-signed URL can be created in a couple of lines of code and does not require and API call back to Amazon S3.

    The benefit of using pre-signed URLs is that your application determines who is entitled to view objects. For example, a user could choose to share a video with another user. Your application would permit the other user to view this shared video. It would not require any changes to IAM or bucket policies.

    See: Amazon S3 pre-signed URLs

    Also, if you wish to grant access to an Amazon S3 bucket to specific IAM Users (that is, users within your organization, rather than application users), it is better to grant access on the IAM User rather than via an Amazon S3 bucket. If there are many users, you can create an IAM Group that contains multiple IAM Users, and then put the policy on the IAM Group. Bucket Policies should generally be used for granting access to "everyone" rather than specific IAM Users.

    In general, it is advisable to avoid using Deny policies since they can be difficult to write correctly and might inadvertently deny access to your Admin staff. It is better to limit what is being Allowed, rather than having to combine Allow and Deny.

    0 讨论(0)
提交回复
热议问题