]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Swift's TempURL can handle temp_url_expires written in ISO8601. 16658/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Fri, 28 Jul 2017 15:19:46 +0000 (11:19 -0400)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Thu, 13 Sep 2018 17:23:11 +0000 (19:23 +0200)
Fixes: http://tracker.ceph.com/issues/20795
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/rgw/rgw_swift_auth.cc
src/rgw/rgw_swift_auth.h

index 571a6286031efc097a32bc5971c26ea2b9e31adc..21bab6cd4bbfb5ac1cf8f18f27796e164bf9a354 100644 (file)
@@ -121,6 +121,19 @@ void TempURLEngine::get_owner_info(const req_state* const s,
   }
 }
 
+std::string TempURLEngine::convert_from_iso8601(std::string expires) const
+{
+  /* Swift's TempURL allows clients to send the expiration as ISO8601-
+   * compatible strings. Though, only plain UNIX timestamp are taken
+   * for the HMAC calculations. We need to make the conversion. */
+  struct tm date_t;
+  if (!parse_iso8601(expires.c_str(), &date_t, nullptr, true)) {
+    return std::move(expires);
+  } else {
+    return std::to_string(internal_timegm(&date_t));
+  }
+}
+
 bool TempURLEngine::is_expired(const std::string& expires) const
 {
   string err;
@@ -254,7 +267,8 @@ TempURLEngine::authenticate(const req_state* const s) const
    * never returns nullptr. If the requested parameter is absent, we will
    * get the empty string. */
   const std::string& temp_url_sig = s->info.args.get("temp_url_sig");
-  const std::string& temp_url_expires = s->info.args.get("temp_url_expires");
+  const std::string& temp_url_expires = \
+    convert_from_iso8601(s->info.args.get("temp_url_expires"));
 
   if (temp_url_sig.empty() || temp_url_expires.empty()) {
     return result_t::deny();
index d3d1e52db675102a0467752d7771d0476754e75c..0fb95d741ec5baa9dac8ec2bffd4582c877b23a4 100644 (file)
@@ -45,6 +45,7 @@ class TempURLEngine : public rgw::auth::Engine {
   /* Helper methods. */
   void get_owner_info(const req_state* s,
                       RGWUserInfo& owner_info) const;
+  std::string convert_from_iso8601(std::string expires) const;
   bool is_applicable(const req_state* s) const noexcept;
   bool is_expired(const std::string& expires) const;