Skip to content

Commit 759fb7f

Browse files
rgw: make jwks url verification configurable
Added `rgw_enable_jwks_url_verification` to control verification. Signed-off-by: Alex Wojno <[email protected]>
1 parent b5e0142 commit 759fb7f

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

src/common/options/rgw.yaml.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,17 @@ options:
11661166
see_also:
11671167
- rgw_keystone_verify_ssl
11681168
with_legacy: true
1169+
- name: rgw_enable_jwks_url_verification
1170+
type: bool
1171+
level: advanced
1172+
desc: Enable JWKS url verification for AWS compliance
1173+
long_desc:
1174+
Verifies the security of the JWKS url endpoint using the client provided thumbprints
1175+
for AWS compliance. If turned on, the legacy verification option of using thumbprints
1176+
to verify JWT x5c certs is disabled.
1177+
default: false
1178+
services:
1179+
- rgw
11691180
# The following are tunables for caches of RGW NFS (and other file
11701181
# client) objects.
11711182
#

src/rgw/rgw_rest_sts.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,14 @@ WebTokenEngine::validate_signature_using_n_e(const DoutPrefixProvider* dpp, cons
577577
return true;
578578
}
579579

580-
bool WebTokenEngine::validate_cert_url(const DoutPrefixProvider* dpp, const std::string& cert_url,
580+
bool WebTokenEngine::verify_oidc_thumbprint(const DoutPrefixProvider* dpp, const std::string& cert_url,
581581
const std::vector<std::string>& thumbprints) const
582582
{
583+
if (!cct->_conf.get_val<bool>("rgw_enable_jwks_url_verification")) {
584+
ldpp_dout(dpp, 5) << "Verification of JWKS endpoint is turned off." << dendl;
585+
return true;
586+
}
587+
583588
// Fetch and verify cert according to https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc_verify-thumbprint.html
584589
const auto hostname = get_top_level_domain_from_host(dpp, cert_url);
585590
ldpp_dout(dpp, 20) << "Validating hostname: " << hostname << dendl;
@@ -606,7 +611,7 @@ WebTokenEngine::validate_signature(const DoutPrefixProvider* dpp, const jwt::dec
606611
{
607612
if (algorithm != "HS256" && algorithm != "HS384" && algorithm != "HS512") {
608613
const auto cert_url = get_cert_url(iss, dpp, y);
609-
if (cert_url.empty() || !validate_cert_url(dpp, cert_url, thumbprints)) {
614+
if (cert_url.empty() || !verify_oidc_thumbprint(dpp, cert_url, thumbprints)) {
610615
ldpp_dout(dpp, 5) << "Not able to validate JWKS url with registered thumbprints" << dendl;
611616
throw std::system_error(EINVAL, std::system_category());
612617
}
@@ -646,10 +651,11 @@ WebTokenEngine::validate_signature(const DoutPrefixProvider* dpp, const jwt::dec
646651
if (JSONDecoder::decode_json("x5c", x5c, &k_parser)) {
647652
string cert;
648653
bool found_valid_cert = false;
654+
bool skip_thumbprint_verification = cct->_conf.get_val<bool>("rgw_enable_jwks_url_verification");
649655
for (auto& it : x5c) {
650656
cert = "-----BEGIN CERTIFICATE-----\n" + it + "\n-----END CERTIFICATE-----";
651657
ldpp_dout(dpp, 20) << "Certificate is: " << cert.c_str() << dendl;
652-
if (is_cert_valid(thumbprints, cert)) {
658+
if (skip_thumbprint_verification || is_cert_valid(thumbprints, cert)) {
653659
found_valid_cert = true;
654660
break;
655661
}
@@ -737,7 +743,7 @@ WebTokenEngine::validate_signature(const DoutPrefixProvider* dpp, const jwt::dec
737743
return;
738744
}
739745
}
740-
ldpp_dout(dpp, 10) << "Bare key parameters are not present for key" << dendl;
746+
ldpp_dout(dpp, 10) << "Bare key parameters (n&e) are not present for key" << dendl;
741747
}
742748
}
743749
} //end k_parser.parse

src/rgw/rgw_rest_sts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class WebTokenEngine : public rgw::auth::Engine {
6969
std::string connect_to_host_get_cert_chain(const DoutPrefixProvider* dpp, const std::string& hostname, int port = 443) const;
7070
std::string get_top_level_domain_from_host(const DoutPrefixProvider* dpp, const std::string& hostname) const;
7171
std::string extract_last_certificate(const DoutPrefixProvider* dpp, const std::string& pem_chain) const;
72-
bool validate_cert_url(const DoutPrefixProvider* dpp, const std::string& cert_url,
72+
bool verify_oidc_thumbprint(const DoutPrefixProvider* dpp, const std::string& cert_url,
7373
const std::vector<std::string>& thumbprints) const;
7474
void shutdown_ssl(const DoutPrefixProvider* dpp, SSL* ssl, SSL_CTX* ctx) const;
7575

0 commit comments

Comments
 (0)