• 限制对特定 HTTP 引用站点的访问


    存储桶策略的大小限制为 20 KB。

    假设您拥有一个网站,其域名为 (www.example.com 或 example.com),并且带有指向存储在 S3 存储桶中的照片和视频的链接 examplebucket。默认情况下,所有 S3 资源都是私有的,因此只有创建资源的 AWS 账户才能访问它们。要允许从您的网站对这些对象进行读取访问,您可以添加一个存储桶策略允许 s3:GetObject 权限,并附带使用 aws:Referer 键的条件,即获取请求必须来自特定的网页。以下策略指定带有 StringLike 条件键的 aws:Referer 条件。

    {
    "Version":"2012-10-17",
    "Id":"http referer policy example",
    "Statement":[
    {
    "Sid":"Allow get requests originating from www.example.com and example.com.",
    "Effect":"Allow",
    "Principal":"*",
    "Action":"s3:GetObject",
    "Resource":"arn:aws:s3:::examplebucket/*",
    "Condition":{
    "StringLike":{"aws:Referer":["http://www.example.com/*","http://example.com/*"]}
    }
    }
    ]
    }

    确保您使用的浏览器在请求中包含 http referer 标头。

    您可以通过向存储桶策略添加显式拒绝,更好地保护对 examplebucket 存储桶中的对象的访问,如下面的示例所示。显式拒绝将取代您使用其他方法 (如 ACL 或用户策略) 可能已授予 examplebucket 存储桶中的对象的任何许可。

    {
    "Version": "2012-10-17",
    "Id": "http referer policy example",
    "Statement": [
    {
    "Sid": "Allow get requests referred by www.example.com and example.com.",
    "Effect": "Allow",
    "Principal": "*",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::examplebucket/*",
    "Condition": {
    "StringLike": {"aws:Referer": ["http://www.example.com/*","http://example.com/*"]}
    }
    },
    {
    "Sid": "Explicit deny to ensure requests are allowed only from specific referer.",
    "Effect": "Deny",
    "Principal": "*",
    "Action": "s3:*",
    "Resource": "arn:aws:s3:::examplebucket/*",
    "Condition": {
    "StringNotLike": {"aws:Referer": ["http://www.example.com/*","http://example.com/*"]}
    }
    }
    ]
    }

    向 Amazon CloudFront Origin Identity 授予权限

    下面的示例中,存储桶策略向 CloudFront Origin Identity 授予获取 (列出) Amazon S3 存储桶中所有对象的权限。CloudFront Origin Identity 用于启用 CloudFront 的私有内容功能。该策略使用 CanonicalUser 前缀而不是 AWS 来指定规范用户 ID。要了解有关提供私有内容的 CloudFront 支持的更多信息,请参阅 Amazon CloudFront 开发人员指南 中的提供私有内容主题。您必须为您的 CloudFront 分配的原始访问标识指定规范用户 ID。有关查找规范用户 ID 的说明,请参阅在策略中指定委托人

    {
    "Version":"2012-10-17",
    "Id":"PolicyForCloudFrontPrivateContent",
    "Statement":[
    {
    "Sid":" Grant a CloudFront Origin Identity access to support private content",
    "Effect":"Allow",
    "Principal":{"CanonicalUser":"CloudFront Origin Identity Canonical User ID"},
    "Action":"s3:GetObject",
    "Resource":"arn:aws:s3:::examplebucket/*"
    }
    ]
    }

  • 相关阅读:
    Entity Framework Code-First(17):Database Initialization Strategy
    Entity Framework Code-First(16):Move Configurations
    Entity Framework Code-First(15):Cascade Delete
    Entity Framework Code-First(14):From Existing DB
    Entity Framework Code-First(13):Configure Many-to-Many
    Entity Framework Code-First(12):Configure One-to-Many
    JAVA-初步认识-第六章-封装思想
    JAVA-初步认识-第六章-封装代码示例
    JAVA-初步认识-第六章-引用数据类型参数传递图解
    JAVA-初步认识-第六章-基本数据类型参数传递图解
  • 原文地址:https://www.cnblogs.com/cloudrivers/p/11331427.html
Copyright © 2020-2023  润新知