Skip to content

Commit 525e79a

Browse files
rgw/s3-notifications: added checks at the REST level when sending user-name/password over unencrypted connection
Signed-off-by: Igor Gomon <[email protected]>
1 parent 8474442 commit 525e79a

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

src/rgw/rgw_rest_pubsub.cc

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ bool verify_transport_security(CephContext *cct, const RGWEnv& env) {
3737
// make sure that if user/password are passed inside URL, it is over secure connection
3838
// update rgw_pubsub_dest to indicate that a password is stored in the URL
3939
bool validate_and_update_endpoint_secret(rgw_pubsub_dest& dest, CephContext *cct,
40-
const RGWEnv& env, std::string& message)
40+
const req_info& ri, std::string& message)
4141
{
4242
if (dest.push_endpoint.empty()) {
4343
return true;
@@ -48,11 +48,31 @@ bool validate_and_update_endpoint_secret(rgw_pubsub_dest& dest, CephContext *cct
4848
message = "Malformed URL for push-endpoint";
4949
return false;
5050
}
51+
52+
const auto& args=ri.args;
53+
auto topic_user_name=args.get_optional("user-name");
54+
auto topic_password=args.get_optional("password");
55+
56+
// check if username/password was already supplied via topic attributes
57+
// and if also provided as part of the endpoint URL issue a warning
58+
if (topic_user_name.has_value()) {
59+
if (!user.empty()) {
60+
message = "Username provided via both topic attributes and endpoint URL: using topic attributes";
61+
}
62+
user = topic_user_name.get();
63+
}
64+
if (topic_password.has_value()) {
65+
if (!password.empty()) {
66+
message = "Password provided via both topic attributes and endpoint URL: using topic attributes";
67+
}
68+
password = topic_password.get();
69+
}
70+
5171
// this should be verified inside parse_url()
5272
ceph_assert(user.empty() == password.empty());
5373
if (!user.empty()) {
5474
dest.stored_secret = true;
55-
if (!verify_transport_security(cct, env)) {
75+
if (!verify_transport_security(cct, *ri.env)) {
5676
message = "Topic contains secrets that must be transmitted over a secure transport";
5777
return false;
5878
}
@@ -241,7 +261,7 @@ class RGWPSCreateTopicOp : public RGWOp {
241261
s->info.args.get_int("max_retries", reinterpret_cast<int *>(&dest.max_retries), rgw::notify::DEFAULT_GLOBAL_VALUE);
242262
s->info.args.get_int("retry_sleep_duration", reinterpret_cast<int *>(&dest.retry_sleep_duration), rgw::notify::DEFAULT_GLOBAL_VALUE);
243263

244-
if (!validate_and_update_endpoint_secret(dest, s->cct, *s->info.env, s->err.message)) {
264+
if (!validate_and_update_endpoint_secret(dest, s->cct, s->info, s->err.message)) {
245265
return -EINVAL;
246266
}
247267
// Store topic Policy.
@@ -729,7 +749,7 @@ class RGWPSSetTopicAttributesOp : public RGWOp {
729749
rgw::notify::DEFAULT_GLOBAL_VALUE);
730750
} else if (attribute_name == "push-endpoint") {
731751
dest.push_endpoint = s->info.args.get("AttributeValue");
732-
if (!validate_and_update_endpoint_secret(dest, s->cct, *s->info.env, s->err.message)) {
752+
if (!validate_and_update_endpoint_secret(dest, s->cct, s->info, s->err.message)) {
733753
return -EINVAL;
734754
}
735755
} else if (attribute_name == "Policy") {

0 commit comments

Comments
 (0)