]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: don't try to authenticate a CORS preflight request
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 28 Aug 2014 00:44:18 +0000 (17:44 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 23 Sep 2014 20:55:48 +0000 (13:55 -0700)
Fixes: #8718
Backport: firefly

CORS preflight requests don't need to be authenticated. Treat them as
coming from anonymous user.

Reported-by: Robert Hubbard <bobby.hubbard@garmin.com>
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit 848fcf7871e07fc689bdcd18943ace36b2f4906e)

src/rgw/rgw_rest_s3.cc
src/rgw/rgw_rest_swift.cc

index c7961f4a9c53443802937b71d3d1e80b200f3985..602a886e082c748b24096b1da9d35015a88e38f8 100644 (file)
@@ -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 {
index b56207934f69cae50b1a075bfec4d9e4cb6d80da..9bdb811cd6ac60fff31b8ac47835c0d3d1443d07 100644 (file)
@@ -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;