示例 本节主要列举Bucket Policy示例。 下面是一个定义Referer Policy的例子 配置 Bucket(名为 examplebucket) 的访问策略: 允许特定子用户(test1,其根用户 ID为 32fefj64y54gc)访问此 Bucket 资源,并且要求请求包含特定的 Referer 头(“ 。 { "Version":"20121017", "Id":"", "Statement":[ { "Sid":"", "Effect":"Allow", "Principal":{ "CTYUN": "arn:ctyun:iam::32fefj64y54gc:user/test1" }, "Action":"oos:", "Resource":"arn:ctyun:oos:::examplebucket/", "Condition":{ "StringLike":{ "ctyun:Referer":[ " " ] } } } ] } 下面是一个定义IP Policy的例子 配置 Bucket(名为 examplebucket) 的访问策略: 允许特定子用户(test2,其根用户 ID为 32fefj64y54gc)在特定网段(192.168.143.0/24,但排除 192.168.143.188)内进行访问。 { "Version": "20121017", "Id": "PolicyId1", "Statement": [ { "Sid": "IPAllow", "Effect": "Allow", "Principal": { "CTYUN": "arn:ctyun:iam::32fefj64y54gc:user/test2" }, "Action": "oos:GetObject", "Resource": "arn:ctyun:oos:::examplebucket/", "Condition" : { "IpAddress" : { "ctyun:SourceIp": "192.168.143.0/24" }, "NotIpAddress" : { "ctyun:SourceIp": "192.168.143.188/32" } } } ] } 下面的例子可向匿名用户授予公共读权限 配置 Bucket(名为 examplebucket) 的访问策略:允许任何人读取文件数据。 { "Version":"20121017", "Statement":[ { "Sid":"AddPerm", "Effect":"Allow", "Principal":{ "CTYUN": [""] }, "Action":["oos:GetObject"], "Resource":["arn:ctyun:oos:::examplebucket/"] } ] }