]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use STSEngine::authenticate when post upload with x_amz_security_token 31879/head
authoryuliyang <yuliyang@cmss.chinamobile.com>
Tue, 26 Nov 2019 09:59:11 +0000 (17:59 +0800)
committeryuliyang <yuliyang@cmss.chinamobile.com>
Thu, 28 Nov 2019 03:25:29 +0000 (11:25 +0800)
Signed-off-by: yuliyang <yuliyang@cmss.chinamobile.com>
src/rgw/rgw_common.h
src/rgw/rgw_rest_s3.cc

index cdc85016318cb1d1f928f933c32042eaf8956b85..b1470cd340a698755fd43a866928653469af8f24 100644 (file)
@@ -1648,6 +1648,7 @@ namespace rgw {
   namespace auth {
     namespace s3 {
       class AWSBrowserUploadAbstractor;
+      class STSEngine;
     }
     class Completer;
   }
@@ -2056,6 +2057,7 @@ struct req_state : DoutPrefixProvider {
       friend class RGWPostObj_ObjStore_S3;
       /* Reader. */
       friend class rgw::auth::s3::AWSBrowserUploadAbstractor;
+      friend class rgw::auth::s3::STSEngine;
 
       std::string access_key;
       std::string signature;
index e9dca22ae8b724a41639870404cb316e240017e9..37d7cb95b145724604a3f60aab660af07e85ae36 100644 (file)
@@ -2308,7 +2308,12 @@ int RGWPostObj_ObjStore_S3::get_policy()
       }
     }
 
-    part_str(parts, "x-amz-security-token", &s->auth.s3_postobj_creds.x_amz_security_token);
+    if (part_str(parts, "x-amz-security-token", &s->auth.s3_postobj_creds.x_amz_security_token)) {
+      if (s->auth.s3_postobj_creds.x_amz_security_token.size() == 0) {
+        err_msg = "Invalid token";
+        return -EINVAL;
+      }
+    }
 
     /* FIXME: this is a makeshift solution. The browser upload authentication will be
      * handled by an instance of rgw::auth::Completer spawned in Handler's authorize()
@@ -5099,7 +5104,8 @@ rgw::auth::s3::STSEngine::authenticate(
   const req_state* const s) const
 {
   if (! s->info.args.exists("X-Amz-Security-Token") &&
-      ! s->info.env->exists("HTTP_X_AMZ_SECURITY_TOKEN")) {
+      ! s->info.env->exists("HTTP_X_AMZ_SECURITY_TOKEN") &&
+      s->auth.s3_postobj_creds.x_amz_security_token.empty()) {
     return result_t::deny();
   }