From: Marc Singer Date: Thu, 7 Mar 2024 17:46:21 +0000 (+0100) Subject: rgw: allow user disabling presigned urls in rgw configuration X-Git-Tag: v17.2.8~103^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=038d0624b5ad45d08e39fa40abbf002ee7a612a1;p=ceph.git rgw: allow user disabling presigned urls in rgw configuration Fixes: https://tracker.ceph.com/issues/64797 Signed-off-by: Marc Singer (cherry picked from commit 5e7a78c) Conflicts: src/rgw/rgw_auth.cc src/rgw/rgw_common.h - quincy does not do signature url expiration check; removed --- diff --git a/src/common/options/rgw.yaml.in b/src/common/options/rgw.yaml.in index e82a0147b1ca..b908b7bd8a05 100644 --- a/src/common/options/rgw.yaml.in +++ b/src/common/options/rgw.yaml.in @@ -871,6 +871,14 @@ options: services: - rgw with_legacy: true +- name: rgw_s3_auth_disable_signature_url + type: bool + level: advanced + desc: Should authentification with presigned URLs be disabled + long_desc: 'If enabled, any request that is presigned with either V2 or V4 signature will be denied' + default: false + services: + - rgw - name: rgw_barbican_url type: str level: advanced diff --git a/src/rgw/rgw_auth.cc b/src/rgw/rgw_auth.cc index 369627c6d7b8..e5925ee5f8e8 100644 --- a/src/rgw/rgw_auth.cc +++ b/src/rgw/rgw_auth.cc @@ -299,6 +299,11 @@ rgw::auth::Strategy::apply(const DoutPrefixProvider *dpp, const rgw::auth::Strat * nullptr inside. */ ldpp_dout(dpp, 5) << "Failed the auth strategy, reason=" << result.get_reason() << dendl; + // Special handling for disabled presigned URL + if (result.get_reason() == ERR_PRESIGNED_URL_DISABLED) { + result = result_t::deny(-EPERM); + set_req_state_err(s, -EPERM, "Presigned URLs are disabled by admin"); + } return result.get_reason(); } diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index c6f79c35fa85..ac02c85558d8 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -266,6 +266,7 @@ using ceph::crypto::MD5; #define ERR_OBJECT_NOT_APPENDABLE 2220 #define ERR_INVALID_BUCKET_STATE 2221 #define ERR_INVALID_OBJECT_STATE 2222 +#define ERR_PRESIGNED_URL_DISABLED 2223 #define ERR_BUSY_RESHARDING 2300 #define ERR_NO_SUCH_ENTITY 2301 diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index bda2f2f3c511..c019f0607e71 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -5439,13 +5439,18 @@ AWSGeneralAbstractor::get_auth_data(const req_state* const s) const AwsRoute route; std::tie(version, route) = discover_aws_flavour(s->info); - if (version == AwsVersion::V2) { - return get_auth_data_v2(s); - } else if (version == AwsVersion::V4) { - return get_auth_data_v4(s, route == AwsRoute::QUERY_STRING); + if (! s->cct->_conf->rgw_s3_auth_disable_signature_url) { + if (version == AwsVersion::V2) { + return get_auth_data_v2(s); + } else if (version == AwsVersion::V4) { + return get_auth_data_v4(s, route == AwsRoute::QUERY_STRING); + } else { + /* FIXME(rzarzynski): handle anon user. */ + throw -EINVAL; + } } else { - /* FIXME(rzarzynski): handle anon user. */ - throw -EINVAL; + ldpp_dout(s, 0) << "Presigned URLs are disabled by admin" << dendl; + throw -ERR_PRESIGNED_URL_DISABLED; } }