From: Radoslaw Zarzynski Date: Thu, 13 Apr 2017 19:13:10 +0000 (+0200) Subject: rgw: eradicate req_state::http_auth. X-Git-Tag: v12.1.0~155^2~62 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b18996c5d6553128a86ae7a53269c832a9c2b117;p=ceph.git rgw: eradicate req_state::http_auth. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index 365cd86cb4ab..6052cfd53884 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -280,7 +280,6 @@ req_state::req_state(CephContext* _cct, RGWEnv* e, RGWUserInfo* u) bucket_exists = false; has_bad_meta = false; length = NULL; - http_auth = NULL; local_source = false; obj_ctx = NULL; diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 30234bb9ae01..36afd3dbfc7e 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -1821,7 +1821,6 @@ struct req_state { string canned_acl; bool has_acl_header; - const char *http_auth; bool local_source; /* source is local */ int prot_flags; diff --git a/src/rgw/rgw_rest.cc b/src/rgw/rgw_rest.cc index 140d434e737a..42cc7d7404d8 100644 --- a/src/rgw/rgw_rest.cc +++ b/src/rgw/rgw_rest.cc @@ -2353,8 +2353,6 @@ int RGWREST::preprocess(struct req_state *s, rgw::io::BasicClient* cio) } } - s->http_auth = info.env->get("HTTP_AUTHORIZATION"); - if (g_conf->rgw_print_continue) { const char *expect = info.env->get("HTTP_EXPECT"); s->expect_cont = (expect && !strcasecmp(expect, "100-continue")); diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index 7485a9b67adb..123954b71398 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -3362,7 +3362,10 @@ int RGW_Auth_S3::authorize(RGWRados* const store, return 0; } - if (!s->http_auth || !(*s->http_auth)) { + /* TODO(rzarzynski): eradicate the double check on HTTP_AUTHORIZATION. + * See couple for next commits. */ + const char* http_auth = s->info.env->get("HTTP_AUTHORIZATION"); + if (!http_auth || !(*http_auth)) { /* AWS4 */ @@ -3398,13 +3401,13 @@ int RGW_Auth_S3::authorize(RGWRados* const store, /* AWS4 */ - if (!strncmp(s->http_auth, "AWS4-HMAC-SHA256", 16)) { + if (!strncmp(http_auth, "AWS4-HMAC-SHA256", 16)) { return authorize_v4(store, s); } /* AWS2 */ - if (!strncmp(s->http_auth, "AWS ", 4)) { + if (!strncmp(http_auth, "AWS ", 4)) { return authorize_v2(store, auth_registry, s); } @@ -3558,7 +3561,8 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s, bool force_b return -ENOMEM; } - if ((!s->http_auth) || !(*s->http_auth)) { + const char* http_auth = s->info.env->get("HTTP_AUTHORIZATION"); + if ((!http_auth) || !(*http_auth)) { /* auth ships with req params ... */ @@ -3623,7 +3627,7 @@ int RGW_Auth_S3::authorize_v4(RGWRados *store, struct req_state *s, bool force_b using_qs = false; - string auth_str = s->http_auth; + string auth_str = http_auth; #define AWS4_HMAC_SHA256_STR "AWS4-HMAC-SHA256" #define CREDENTIALS_PREFIX_LEN (sizeof(AWS4_HMAC_SHA256_STR) - 1) @@ -4253,7 +4257,8 @@ rgw::auth::s3::RGWS3V2Extractor::get_auth_data(const req_state* const s) const std::string signature; bool qsr = false; - if (! s->http_auth || s->http_auth[0] == '\0') { + const char* http_auth = s->info.env->get("HTTP_AUTHORIZATION"); + if (! http_auth || http_auth[0] == '\0') { /* Credentials are provided in query string. We also need to verify * the "Expires" parameter now. */ access_key_id = s->info.args.get("AWSAccessKeyId"); @@ -4272,7 +4277,7 @@ rgw::auth::s3::RGWS3V2Extractor::get_auth_data(const req_state* const s) const } } else { /* The "Authorization" HTTP header is being used. */ - const std::string auth_str(s->http_auth + strlen("AWS ")); + const std::string auth_str(http_auth + strlen("AWS ")); const size_t pos = auth_str.rfind(':'); if (pos != std::string::npos) { access_key_id = auth_str.substr(0, pos);