Amazon s3: how to set file viewing permission -


i developing web system uses amazon s3 file server. files uploaded s3 directly , corresponding urls written html page. example, have file @ s3 location is:

https://myaccount.amazonaws.com/files/abc.png 

and in html put:

<img src="https://myaccount.amazonaws.com/files/abc.png"> 

the image show correctly in browser. however, happen have set permission on s3 everyone viewable, means file open public.

how restrict file viewing permission members of site, not public?

there several ways grant access amazon s3 objects:

  • access control lists (acls) on each individual object
  • a bucket policy on specific bucket
  • an iam policy (identity , access management) on specific user/group
  • signed urls (signed, time-limited urls)

the first question, however, how define "the members of site, not public". assume mean "to people want allow access app, , not others", , app knows these users, not defined in iam. (iam used store users access aws environment. should not used track users of application.)

for situation, recommend use of signed urls. way work is:

  • the object kept private (no public access)
  • your application constructs signed url grants temporary access object
  • when sending html users, refer objects via signed url (eg pictures, downloadable documents)

so, application responsible determining whether should allowed access s3 content and, if so, permit access via signed url.

for details on constructing signed url, see:

basically, uses permissions associated iam user does have access object, , uses hash of iam user's secret key 'sign' request.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -