From: Yehuda Sadeh Date: Thu, 28 Aug 2014 00:44:18 +0000 (-0700) Subject: rgw: don't try to authenticate a CORS preflight request X-Git-Tag: v0.80.8~64^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6fee71154d838868807fd9824d829c8250d9d2eb;p=ceph.git rgw: don't try to authenticate a CORS preflight request Fixes: #8718 Backport: firefly CORS preflight requests don't need to be authenticated. Treat them as coming from anonymous user. Reported-by: Robert Hubbard Signed-off-by: Yehuda Sadeh (cherry picked from commit 848fcf7871e07fc689bdcd18943ace36b2f4906e) --- diff --git a/src/rgw/rgw_rest_s3.cc b/src/rgw/rgw_rest_s3.cc index c7961f4a9c5..602a886e082 100644 --- a/src/rgw/rgw_rest_s3.cc +++ b/src/rgw/rgw_rest_s3.cc @@ -2047,6 +2047,12 @@ int RGW_Auth_S3_Keystone_ValidateToken::validate_s3token(const string& auth_id, return 0; } +static void init_anon_user(struct req_state *s) +{ + rgw_get_anon_user(s->user); + s->perm_mask = RGW_PERM_FULL_CONTROL; +} + /* * verify that a signed request comes from the keyholder * by checking the signature against our locally-computed version @@ -2067,6 +2073,11 @@ int RGW_Auth_S3::authorize(RGWRados *store, struct req_state *s) return -EPERM; } + if (s->op == OP_OPTIONS) { + init_anon_user(s); + return 0; + } + if (!s->http_auth || !(*s->http_auth)) { auth_id = s->info.args.get("AWSAccessKeyId"); if (auth_id.size()) { @@ -2080,8 +2091,7 @@ int RGW_Auth_S3::authorize(RGWRados *store, struct req_state *s) qsr = true; } else { /* anonymous access */ - rgw_get_anon_user(s->user); - s->perm_mask = RGW_PERM_FULL_CONTROL; + init_anon_user(s); return 0; } } else { diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index b56207934f6..9bdb811cd6a 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -776,7 +776,8 @@ RGWOp *RGWHandler_ObjStore_Obj_SWIFT::op_options() int RGWHandler_ObjStore_SWIFT::authorize() { - if (!s->os_auth_token && s->info.args.get("temp_url_sig").empty()) { + if ((!s->os_auth_token && s->info.args.get("temp_url_sig").empty()) || + (s->op == OP_OPTIONS)) { /* anonymous access */ rgw_get_anon_user(s->user); s->perm_mask = RGW_PERM_FULL_CONTROL;