rgw bucket 防盗链

防盗链实现方式

https://yq.aliyun.com/articles/57931

签名URL可以和Referer白名单功能一起使用,可以增加防盗链的效果。

设置Referer

原理:https://blog.csdn.net/qq_38002337/article/details/79664251

RefererHTTP Header的一部分,当浏览器向网站Web服务器发送请求的时候,通常会带上Referer,告诉服务器此次请求的链接来源。

通过设置访问白名单,限制只有  HTTP HTTPS header 中包含referer 为白名单里的地址时的请求才能访问

校验referer

https://help.aliyun.com/knowledge_detail/39521.html?spm=a2c4g.11186631.2.1.1fb61324V6uG8e

1.设置桶的文件为public-read

2.curl http://100.69.4.118:7480/haj-1-b-1-test/file_22_8

ceph

acl

rgw_acl.h:   RGWAccessControlList+ACLOwner --> RGWAccessControlPolicy

 

type;    //canon_user,email_user,group,referer

permission;  //read,write,read_acp,write_acp,read_objs,write_objs,full_control

group;    //all_users,authenticated_users

 

 

rgw_acl_s3.cc:   ACLGrant_S3 不支持referer类型的acl设置

rgw_acl_swift.ccRGWAccessControlPolicy_SWIFT 支持referer设置

iam policy

使用s3cmd setpolicy命令设置的policy会放到bucketxattriam-policy变量里

权限关系

setpolicy可以设置的权限包括了s3:GetObjects3:DeleteBucket等等,何种命令对应这些权限查看:rgw_op.cc里各个命令的verify_permission()函数,如:

 

rados 命令

使用rados 命令查看bucketxattr属性

 

aws iam policy

policy的变量解释,写法及技巧:

https://www.infoq.cn/article/aws-iam-dive-in

比较全的实例说明:

https://docs.aws.amazon.com/zh_cn/AmazonS3/latest/dev/example-bucket-policies.html#example-bucket-policies-use-case-3

s3cmd

命令

设置policy: s3cmd setpolicy policy_referer.json s3://haj-1-b-1-test

查看policy: s3cmd info s3://haj-1-b-1-test

删除policy: s3cmd delpolicy s3://haj-1-b-1-test   

policy文件

测试

基本规则

policy文件如 "StringEquals":{"aws:Referer":["100.69.4.118"]}

bucket acl

http head

owner操作

http code

private

None

conn.get_bucket

403

public-read

None

conn.get_bucket

200

private/public-read

headers={"REFERER":"100.69.4.108"}

conn.get_bucket

403

private/public-read

headers={"REFERER":None}

conn.get_bucket

403

private/public-read

 

headers={"REFERER":"100.69.4.118"}

conn.get_bucket

200

 

结论:若http里不带referer则不校验,若httpreferer则校验

设置多个固定值

如下图,设置aws:Referer 只需匹配116或者118的一个即可

设置带*号的网站

不允许referer为空

需要加上“IfExists

 

参考链接

华为云对象存储s3cmd:

https://wenku.baidu.com/view/446ccd898ad63186bceb19e8b8f67c1cfad6eea7.html

ceph代码解析:

https://www.jianshu.com/p/a1aab0d3eeef

阿里云防盗链:

https://yq.aliyun.com/articles/57931

ceph官方文档:

http://docs.ceph.com/docs/master/radosgw/bucketpolicy/

boto3文档:

https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#bucketpolicy

黑白名单设置区别:

https://support.huaweicloud.com/devg-obs/zh-cn_topic_0118383424.html

 

 

 

 

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值