1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab ft=cpp
/*
* Ceph - scalable distributed file system
*
* Copyright contributors to the Ceph project
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#include "rgw_iam_managed_policy.h"
#include "rgw_iam_policy.h"
namespace rgw::IAM {
// Type: AWS managed policy
// Creation time: February 06, 2015, 18:40 UTC
// Edited time: June 21, 2019, 19:40 UTC
// ARN: arn:aws:iam::aws:policy/IAMFullAccess
// Policy version: v2 (default)
static constexpr std::string_view IAMFullAccess = R"(
{
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : [
"iam:*",
"organizations:DescribeAccount",
"organizations:DescribeOrganization",
"organizations:DescribeOrganizationalUnit",
"organizations:DescribePolicy",
"organizations:ListChildren",
"organizations:ListParents",
"organizations:ListPoliciesForTarget",
"organizations:ListRoots",
"organizations:ListPolicies",
"organizations:ListTargetsForPolicy"
],
"Resource" : "*"
}
]
})";
// Type: AWS managed policy
// Creation time: February 06, 2015, 18:40 UTC
// Edited time: January 25, 2018, 19:11 UTC
// ARN: arn:aws:iam::aws:policy/IAMReadOnlyAccess
// Policy version: v4 (default)
static constexpr std::string_view IAMReadOnlyAccess = R"(
{
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : [
"iam:GenerateCredentialReport",
"iam:GenerateServiceLastAccessedDetails",
"iam:Get*",
"iam:List*",
"iam:SimulateCustomPolicy",
"iam:SimulatePrincipalPolicy"
],
"Resource" : "*"
}
]
})";
// Type: AWS managed policy
// Creation time: February 06, 2015, 18:41 UTC
// Edited time: February 06, 2015, 18:41 UTC
// ARN: arn:aws:iam::aws:policy/AmazonSNSFullAccess
// Policy version: v1 (default)
static constexpr std::string_view AmazonSNSFullAccess = R"(
{
"Version" : "2012-10-17",
"Statement" : [
{
"Action" : [
"sns:*"
],
"Effect" : "Allow",
"Resource" : "*"
}
]
})";
// Type: AWS managed policy
// Creation time: February 06, 2015, 18:41 UTC
// Edited time: February 06, 2015, 18:41 UTC
// ARN: arn:aws:iam::aws:policy/AmazonSNSReadOnlyAccess
// Policy version: v1 (default)
static constexpr std::string_view AmazonSNSReadOnlyAccess = R"(
{
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : [
"sns:GetTopicAttributes",
"sns:List*"
],
"Resource" : "*"
}
]
})";
// Type: AWS managed policy
// Creation time: February 06, 2015, 18:40 UTC
// Edited time: September 27, 2021, 20:16 UTC
// ARN: arn:aws:iam::aws:policy/AmazonS3FullAccess
// Policy version: v2 (default)
static constexpr std::string_view AmazonS3FullAccess = R"(
{
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : [
"s3:*",
"s3-object-lambda:*"
],
"Resource" : "*"
}
]
})";
// Type: AWS managed policy
// Creation time: February 06, 2015, 18:40 UTC
// Edited time: August 10, 2023, 21:31 UTC
// ARN: arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess
// Policy version: v3 (default)
static constexpr std::string_view AmazonS3ReadOnlyAccess = R"(
{
"Version" : "2012-10-17",
"Statement" : [
{
"Effect" : "Allow",
"Action" : [
"s3:Get*",
"s3:List*",
"s3:Describe*",
"s3-object-lambda:Get*",
"s3-object-lambda:List*"
],
"Resource" : "*"
}
]
})";
auto get_managed_policy(CephContext* cct, std::string_view arn)
-> std::optional<Policy>
{
const std::string* tenant = nullptr;
constexpr bool reject = false; // reject_invalid_principals
if (arn == "arn:aws:iam::aws:policy/IAMFullAccess") {
return Policy{cct, tenant, std::string{IAMFullAccess}, reject};
} else if (arn == "arn:aws:iam::aws:policy/IAMReadOnlyAccess") {
return Policy{cct, tenant, std::string{IAMReadOnlyAccess}, reject};
} else if (arn == "arn:aws:iam::aws:policy/AmazonSNSFullAccess") {
return Policy{cct, tenant, std::string{AmazonSNSFullAccess}, reject};
} else if (arn == "arn:aws:iam::aws:policy/AmazonSNSReadOnlyAccess") {
return Policy{cct, tenant, std::string{AmazonSNSReadOnlyAccess}, reject};
} else if (arn == "arn:aws:iam::aws:policy/AmazonS3FullAccess") {
return Policy{cct, tenant, std::string{AmazonS3FullAccess}, reject};
} else if (arn == "arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess") {
return Policy{cct, tenant, std::string{AmazonS3ReadOnlyAccess}, reject};
}
return {};
}
void encode(const ManagedPolicies& m, bufferlist& bl, uint64_t f)
{
ENCODE_START(1, 1, bl);
encode(m.arns, bl);
ENCODE_FINISH(bl);
}
void decode(ManagedPolicies& m, bufferlist::const_iterator& bl)
{
DECODE_START(1, bl);
decode(m.arns, bl);
DECODE_FINISH(bl);
}
} // namespace rgw::IAM
|