]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_rest_role.h
a8beb2b54052c2fbb44201db769e6b618d42e049
[ceph.git] / ceph / src / rgw / rgw_rest_role.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 "common/async/yield_context.h"
7
8 #include "rgw_role.h"
9 #include "rgw_rest.h"
10
11 class RGWRestRole : public RGWRESTOp {
12 protected:
13 std::string role_name;
14 std::string role_path;
15 std::string trust_policy;
16 std::string policy_name;
17 std::string perm_policy;
18 std::string path_prefix;
19 std::string max_session_duration;
20 std::multimap<std::string,std::string> tags;
21 std::vector<std::string> tagKeys;
22 std::unique_ptr<rgw::sal::RGWRole> _role;
23 int verify_permission(optional_yield y) override;
24 void send_response() override;
25 virtual uint64_t get_op() = 0;
26 int parse_tags();
27 };
28
29 class RGWRoleRead : public RGWRestRole {
30 public:
31 RGWRoleRead() = default;
32 int check_caps(const RGWUserCaps& caps) override;
33 };
34
35 class RGWRoleWrite : public RGWRestRole {
36 public:
37 RGWRoleWrite() = default;
38 int check_caps(const RGWUserCaps& caps) override;
39 };
40
41 class RGWCreateRole : public RGWRoleWrite {
42 public:
43 RGWCreateRole() = default;
44 int verify_permission(optional_yield y) override;
45 void execute(optional_yield y) override;
46 int get_params();
47 const char* name() const override { return "create_role"; }
48 RGWOpType get_type() override { return RGW_OP_CREATE_ROLE; }
49 uint64_t get_op() override { return rgw::IAM::iamCreateRole; }
50 };
51
52 class RGWDeleteRole : public RGWRoleWrite {
53 public:
54 RGWDeleteRole() = default;
55 void execute(optional_yield y) override;
56 int get_params();
57 const char* name() const override { return "delete_role"; }
58 RGWOpType get_type() override { return RGW_OP_DELETE_ROLE; }
59 uint64_t get_op() override { return rgw::IAM::iamDeleteRole; }
60 };
61
62 class RGWGetRole : public RGWRoleRead {
63 int _verify_permission(const rgw::sal::RGWRole* role);
64 public:
65 RGWGetRole() = default;
66 int verify_permission(optional_yield y) override;
67 void execute(optional_yield y) override;
68 int get_params();
69 const char* name() const override { return "get_role"; }
70 RGWOpType get_type() override { return RGW_OP_GET_ROLE; }
71 uint64_t get_op() override { return rgw::IAM::iamGetRole; }
72 };
73
74 class RGWModifyRole : public RGWRoleWrite {
75 public:
76 RGWModifyRole() = default;
77 void execute(optional_yield y) override;
78 int get_params();
79 const char* name() const override { return "modify_role"; }
80 RGWOpType get_type() override { return RGW_OP_MODIFY_ROLE; }
81 uint64_t get_op() override { return rgw::IAM::iamModifyRole; }
82 };
83
84 class RGWListRoles : public RGWRoleRead {
85 public:
86 RGWListRoles() = default;
87 int verify_permission(optional_yield y) override;
88 void execute(optional_yield y) override;
89 int get_params();
90 const char* name() const override { return "list_roles"; }
91 RGWOpType get_type() override { return RGW_OP_LIST_ROLES; }
92 uint64_t get_op() override { return rgw::IAM::iamListRoles; }
93 };
94
95 class RGWPutRolePolicy : public RGWRoleWrite {
96 public:
97 RGWPutRolePolicy() = default;
98 void execute(optional_yield y) override;
99 int get_params();
100 const char* name() const override { return "put_role_policy"; }
101 RGWOpType get_type() override { return RGW_OP_PUT_ROLE_POLICY; }
102 uint64_t get_op() override { return rgw::IAM::iamPutRolePolicy; }
103 };
104
105 class RGWGetRolePolicy : public RGWRoleRead {
106 public:
107 RGWGetRolePolicy() = default;
108 void execute(optional_yield y) override;
109 int get_params();
110 const char* name() const override { return "get_role_policy"; }
111 RGWOpType get_type() override { return RGW_OP_GET_ROLE_POLICY; }
112 uint64_t get_op() override { return rgw::IAM::iamGetRolePolicy; }
113 };
114
115 class RGWListRolePolicies : public RGWRoleRead {
116 public:
117 RGWListRolePolicies() = default;
118 void execute(optional_yield y) override;
119 int get_params();
120 const char* name() const override { return "list_role_policies"; }
121 RGWOpType get_type() override { return RGW_OP_LIST_ROLE_POLICIES; }
122 uint64_t get_op() override { return rgw::IAM::iamListRolePolicies; }
123 };
124
125 class RGWDeleteRolePolicy : public RGWRoleWrite {
126 public:
127 RGWDeleteRolePolicy() = default;
128 void execute(optional_yield y) override;
129 int get_params();
130 const char* name() const override { return "delete_role_policy"; }
131 RGWOpType get_type() override { return RGW_OP_DELETE_ROLE_POLICY; }
132 uint64_t get_op() override { return rgw::IAM::iamDeleteRolePolicy; }
133 };
134
135 class RGWTagRole : public RGWRoleWrite {
136 public:
137 RGWTagRole() = default;
138 void execute(optional_yield y) override;
139 int get_params();
140 const char* name() const override { return "tag_role"; }
141 RGWOpType get_type() override { return RGW_OP_TAG_ROLE; }
142 uint64_t get_op() override { return rgw::IAM::iamTagRole; }
143 };
144
145 class RGWListRoleTags : public RGWRoleRead {
146 public:
147 RGWListRoleTags() = default;
148 void execute(optional_yield y) override;
149 int get_params();
150 const char* name() const override { return "list_role_tags"; }
151 RGWOpType get_type() override { return RGW_OP_LIST_ROLE_TAGS; }
152 uint64_t get_op() override { return rgw::IAM::iamListRoleTags; }
153 };
154
155 class RGWUntagRole : public RGWRoleWrite {
156 public:
157 RGWUntagRole() = default;
158 void execute(optional_yield y) override;
159 int get_params();
160 const char* name() const override { return "untag_role"; }
161 RGWOpType get_type() override { return RGW_OP_UNTAG_ROLE; }
162 uint64_t get_op() override { return rgw::IAM::iamUntagRole; }
163 };