我这里有此政策,该政策只允许从我的Web应用程序进行访问。但是,如果我在S3上输入对象的URL,我仍然可以访问它。
我还需要设置其他哪些内容,以确保只能从Web应用程序访问存储桶中的项目。
{
"Id": "Policy15721415129441",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt15721415129441",
"Action": [
"s3:GetObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::BUCKET_NAME/*",
"Condition": {
"StringLike": {
"aws:Referer": "https://localhost:55723/*"
}
},
"Principal": {
"AWS": [
"arn:aws:iam::ACC_NO:root"
]
}
}
]
}
CORS配置
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>https://localhost:55723</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>