]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_acl_s3.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rgw / rgw_acl_s3.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 #pragma once
5
6 #include <map>
7 #include <string>
8 #include <iosfwd>
9 #include <include/types.h>
10
11 #include "include/str_list.h"
12 #include "rgw_xml.h"
13 #include "rgw_acl.h"
14 #include "rgw_sal_fwd.h"
15
16 class RGWUserCtl;
17
18 class ACLPermission_S3 : public ACLPermission, public XMLObj
19 {
20 public:
21 ACLPermission_S3() {}
22 virtual ~ACLPermission_S3() override {}
23
24 bool xml_end(const char *el) override;
25 void to_xml(std::ostream& out);
26 };
27
28 class ACLGrantee_S3 : public ACLGrantee, public XMLObj
29 {
30 public:
31 ACLGrantee_S3() {}
32 virtual ~ACLGrantee_S3() override {}
33
34 bool xml_start(const char *el, const char **attr);
35 };
36
37
38 class ACLGrant_S3 : public ACLGrant, public XMLObj
39 {
40 public:
41 ACLGrant_S3() {}
42 virtual ~ACLGrant_S3() override {}
43
44 void to_xml(CephContext *cct, std::ostream& out);
45 bool xml_end(const char *el) override;
46 bool xml_start(const char *el, const char **attr);
47
48 static ACLGroupTypeEnum uri_to_group(std::string& uri);
49 static bool group_to_uri(ACLGroupTypeEnum group, std::string& uri);
50 };
51
52 class RGWAccessControlList_S3 : public RGWAccessControlList, public XMLObj
53 {
54 public:
55 explicit RGWAccessControlList_S3(CephContext *_cct) : RGWAccessControlList(_cct) {}
56 virtual ~RGWAccessControlList_S3() override {}
57
58 bool xml_end(const char *el) override;
59 void to_xml(std::ostream& out);
60
61 int create_canned(ACLOwner& owner, ACLOwner& bucket_owner, const std::string& canned_acl);
62 int create_from_grants(std::list<ACLGrant>& grants);
63 };
64
65 class ACLOwner_S3 : public ACLOwner, public XMLObj
66 {
67 public:
68 ACLOwner_S3() {}
69 virtual ~ACLOwner_S3() override {}
70
71 bool xml_end(const char *el) override;
72 void to_xml(std::ostream& out);
73 };
74
75 class RGWEnv;
76
77 class RGWAccessControlPolicy_S3 : public RGWAccessControlPolicy, public XMLObj
78 {
79 public:
80 explicit RGWAccessControlPolicy_S3(CephContext *_cct) : RGWAccessControlPolicy(_cct) {}
81 virtual ~RGWAccessControlPolicy_S3() override {}
82
83 bool xml_end(const char *el) override;
84
85 void to_xml(std::ostream& out);
86 int rebuild(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver, ACLOwner *owner,
87 RGWAccessControlPolicy& dest, std::string &err_msg);
88 bool compare_group_name(std::string& id, ACLGroupTypeEnum group) override;
89
90 virtual int create_canned(ACLOwner& _owner, ACLOwner& bucket_owner, const std::string& canned_acl) {
91 RGWAccessControlList_S3& _acl = static_cast<RGWAccessControlList_S3 &>(acl);
92 if (_owner.get_id() == rgw_user("anonymous")) {
93 owner = bucket_owner;
94 } else {
95 owner = _owner;
96 }
97 int ret = _acl.create_canned(owner, bucket_owner, canned_acl);
98 return ret;
99 }
100 int create_from_headers(const DoutPrefixProvider *dpp, rgw::sal::Driver* driver,
101 const RGWEnv *env, ACLOwner& _owner);
102 };
103
104 /**
105 * Interfaces with the webserver's XML handling code
106 * to parse it in a way that makes sense for the rgw.
107 */
108 class RGWACLXMLParser_S3 : public RGWXMLParser
109 {
110 CephContext *cct;
111
112 XMLObj *alloc_obj(const char *el) override;
113 public:
114 explicit RGWACLXMLParser_S3(CephContext *_cct) : cct(_cct) {}
115 };