diff options
author | Radoslaw Zarzynski <rzarzyns@redhat.com> | 2017-07-28 17:19:46 +0200 |
---|---|---|
committer | Radoslaw Zarzynski <rzarzyns@redhat.com> | 2018-09-13 19:23:11 +0200 |
commit | 56b8807962b086b1b158b8591137542e921bd71f (patch) | |
tree | 9d1c583079976e19e325b0231e9cb2664d1d50fb /src/rgw/rgw_swift_auth.cc | |
parent | Merge pull request #24077 from alfredodeza/wip-rm35970 (diff) | |
download | ceph-56b8807962b086b1b158b8591137542e921bd71f.tar.xz ceph-56b8807962b086b1b158b8591137542e921bd71f.zip |
rgw: Swift's TempURL can handle temp_url_expires written in ISO8601.
Fixes: http://tracker.ceph.com/issues/20795
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
Diffstat (limited to 'src/rgw/rgw_swift_auth.cc')
-rw-r--r-- | src/rgw/rgw_swift_auth.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/rgw/rgw_swift_auth.cc b/src/rgw/rgw_swift_auth.cc index 571a6286031..21bab6cd4bb 100644 --- a/src/rgw/rgw_swift_auth.cc +++ b/src/rgw/rgw_swift_auth.cc @@ -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(); |