Skip to content
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
458bbd4
wip get urls from dmrpp
hannahilea Oct 28, 2025
be8ecf4
urls available from EffectiveUrlCache
hannahilea Oct 28, 2025
61ffd33
parse s3 credentials from tea endpoint
hannahilea Oct 29, 2025
60271a2
Split SignedUrlCache out of EffectiveUrlCache
hannahilea Oct 29, 2025
a19ee90
Split SignedUrlCache out of EffectiveUrlCache
hannahilea Oct 29, 2025
a926716
wip start adding aws sdk dependence
hannahilea Oct 29, 2025
0a3691d
Merge branch 'hr/HYRAX-1732-TEA-party-3' of https://github.com/OPENDA…
hannahilea Oct 29, 2025
738ae40
Merge branch 'hr/HYRAX-1732-TEA-party-3' of https://github.com/OPENDA…
hannahilea Oct 29, 2025
db5fb39
Add unit test: cache_disabled
hannahilea Oct 30, 2025
ea21df6
Merge branch 'hr/HYRAX-1732-TEA-party-3' of https://github.com/OPENDA…
hannahilea Oct 30, 2025
2e0c4b7
Update test: set_skip_regex
hannahilea Oct 30, 2025
1bce392
Add test: dump
hannahilea Oct 30, 2025
0652066
Fill in credential expiration wip
hannahilea Oct 30, 2025
19a9240
Clear all caches for unit test setup
hannahilea Oct 31, 2025
ff57cd3
Add test and fix behavior: invalid response json
hannahilea Oct 31, 2025
2466331
Test non-http behavior
hannahilea Oct 31, 2025
b384fd9
Add test: cache signed url components
hannahilea Oct 31, 2025
7a3e8a3
Add test: retrieved signed url components
hannahilea Oct 31, 2025
0142bed
Add messages to unit test asserts
hannahilea Oct 31, 2025
4792441
add test for gets3credentials from endpoing
hannahilea Oct 31, 2025
53e288c
remove stale tests
hannahilea Oct 31, 2025
1df8485
Clean up
hannahilea Oct 31, 2025
05d79c8
handle timestamp wrangling differently
hannahilea Oct 31, 2025
c440ee8
update docstrings
hannahilea Oct 31, 2025
aa65428
clean up dump to include all cache maps
hannahilea Oct 31, 2025
01b5669
aws wip
hannahilea Oct 30, 2025
c265781
wip sadness
hannahilea Nov 3, 2025
59ab7e0
Move SignedUrlCache implementation into .cc
hannahilea Nov 5, 2025
cd869e7
move SignedUrlCache from http to aws
hannahilea Nov 6, 2025
c6b2c9d
enable aws signedurlcachetest tests
hannahilea Nov 13, 2025
fd688d3
add helper function for splitting s3 paths
hannahilea Nov 13, 2025
a45935b
add expiration calculation
hannahilea Nov 14, 2025
d56a9cd
safety first
hannahilea Nov 14, 2025
487d098
add docstring remove todo
hannahilea Nov 17, 2025
96a2a10
move warning
hannahilea Nov 17, 2025
14c01e3
temp disable tests to understand travis failure
hannahilea Nov 17, 2025
939c1f2
commit out all signedurlcachetests to see if it still fails
hannahilea Nov 17, 2025
8a0813e
Merge branch 'master' into hr/HYRAX-1732-TEA-party-3
hannahilea Nov 17, 2025
08057a9
fix linking in ngap_container
hannahilea Nov 17, 2025
8d77254
wip linker
hannahilea Nov 17, 2025
39cbd6a
Update mkchk script to show errors where build failed
hannahilea Nov 17, 2025
1b55513
add test output to .gitignore
hannahilea Nov 17, 2025
7708576
fix ngap_container linker
hannahilea Nov 17, 2025
a1de61a
Fix dmrpp_module/unit tests linking
hannahilea Nov 18, 2025
1426168
linker changes; can now make bes, pass all unit tests w/out linker fa…
hannahilea Nov 18, 2025
91cd9d5
Link aws to the standalone
hannahilea Nov 18, 2025
d0a5c6f
fix dmrpp module linking
hannahilea Nov 19, 2025
6b54d8a
re-enable signedurlcachetest
hannahilea Nov 19, 2025
2f6f226
revert unnecessary abspath change
hannahilea Nov 19, 2025
bd5a27d
Merge branch 'master' into hr/HYRAX-1732-TEA-party-3
hannahilea Nov 19, 2025
27352b6
clean up
hannahilea Nov 19, 2025
9dd8da5
more clean-up
hannahilea Nov 19, 2025
d0d57d6
comment out signedurlcachetest to see if everything else will build o…
hannahilea Nov 19, 2025
9f5f155
fix tests link, remove aws link from standalone
hannahilea Nov 20, 2025
0e4b204
revert top makefile.am changes
hannahilea Nov 20, 2025
ad58fb7
Add conf to aws unit-tests and reenable aws tests
hannahilea Nov 20, 2025
3856327
more test fixes
hannahilea Nov 20, 2025
6d768a4
add cmdln test that uses dmrpp
hannahilea Nov 20, 2025
b55605f
print testsuite log from travis
hannahilea Nov 21, 2025
438b6c2
add additional aws dep lib
hannahilea Nov 24, 2025
8f93f33
temp turn off .travis jobs
hannahilea Nov 24, 2025
70cf422
rearrange aws libs to attempt to fix static build
hannahilea Nov 25, 2025
5b6a07d
rearrange more
hannahilea Nov 25, 2025
c8211d8
one more switcharoo...
hannahilea Nov 25, 2025
7991d05
more rearrange
hannahilea Nov 25, 2025
7590c69
welp was making it worse
hannahilea Nov 25, 2025
55f7a77
add dmrpp check that doesn't fail if unauthorized
hannahilea Nov 26, 2025
145740a
temp disable another travis job
hannahilea Nov 26, 2025
b364550
fifteenth time's the charm
hannahilea Nov 26, 2025
1930786
Merge branch 'master' into hr/HYRAX-1732-TEA-party-3
hannahilea Nov 26, 2025
5a55213
you put the right dep in you put the right dep out
hannahilea Nov 26, 2025
41a0155
you put the right dep in and you shake it all about
hannahilea Nov 26, 2025
719a7d1
you do the linky pokey
hannahilea Nov 26, 2025
610e3e6
and you link it all around
hannahilea Nov 26, 2025
ea45f4a
but that's not what it's all about
hannahilea Nov 26, 2025
9f9d3d8
simplify
hannahilea Dec 1, 2025
6a82907
Add s2n now that it is available in hyrax-dependencies
hannahilea Dec 1, 2025
4498abc
Merge branch 'master' into hr/HYRAX-1732-TEA-party-3
hannahilea Dec 8, 2025
fa82269
shot in dark: maybe we don't need aws-crt-cpp
hannahilea Dec 8, 2025
7029be6
comment out travis again for failing fast
hannahilea Dec 8, 2025
d31f1d8
add crt back in
hannahilea Dec 8, 2025
8e347ef
Merge branch 'master' into hr/HYRAX-1732-TEA-party-3
hannahilea Feb 12, 2026
bc9fc2e
Merge branch 'master' into hr/HYRAX-1732-TEA-party-3
hannahilea Feb 12, 2026
8e1ef10
fix build_dmrpp linking
hannahilea Feb 13, 2026
20d56b0
uncomment travis
hannahilea Feb 13, 2026
175a782
remove invalid s2n dep
hannahilea Feb 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,10 @@ add_executable(
http/EffectiveUrl.h
http/EffectiveUrlCache.cc
http/EffectiveUrlCache.h
http/SignedUrlCache.cc
http/SignedUrlCache.h
http/unit-tests/EffectiveUrlCacheTest.cc
http/unit-tests/SignedUrlCacheTest.cc
http/unit-tests/HttpUrlTest.cc
http/unit-tests/RemoteResourceTest.cc
http/unit-tests/AllowedHostsTest.cc
Expand Down
2 changes: 2 additions & 0 deletions http/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ SRCS = CurlUtils.cc \
HttpUtils.cc \
ProxyConfig.cc \
EffectiveUrlCache.cc \
SignedUrlCache.cc \
url_impl.cc \
EffectiveUrl.cc \
AllowedHosts.cc \
Expand All @@ -55,6 +56,7 @@ HDRS = CurlUtils.h \
ProxyConfig.h \
HttpNames.h \
EffectiveUrlCache.h \
SignedUrlCache.h \
url_impl.h \
EffectiveUrl.h \
AllowedHosts.h \
Expand Down
432 changes: 432 additions & 0 deletions http/SignedUrlCache.cc

Large diffs are not rendered by default.

126 changes: 126 additions & 0 deletions http/SignedUrlCache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// -*- mode: c++; c-basic-offset:4 -*-

// This file is part of the BES http package, part of the Hyrax data server.

// Copyright (c) 2025 OPeNDAP, Inc.
// Authors: Nathan Potter <[email protected]>, Hannah Robertson <[email protected]>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.

// Authors:
// ndp Nathan Potter <[email protected]>
// Hannah Robertson <[email protected]>

#ifndef _bes_http_SignedUrlCache_h_
#define _bes_http_SignedUrlCache_h_ 1

#include <memory>
#include <map>
#include <unordered_map>
#include <string>
#include <mutex>

#include "BESObj.h"
#include "BESRegex.h" // for std::unique_ptr<BESRegex>

namespace http {

class EffectiveUrl;
class url;

/**
* This is a singleton class. It is used to associate a URL with its "pre-signed" AWS s3 URL. This means that
* a URL is signed locally rather than sent through a potentially large number of external redirect actions, as
* in EffectiveUrlCache.h. This url location plus the requisite AWS signature headers, from which the requested bytes
* are transmitted, is termed the "effective url" and is stored in an in memory cache (std::map) so that later
* requests may skip the external signing service and just get required bytes from the actual source.
*/
class SignedUrlCache : public BESObj {
public:
typedef std::tuple<std::string, std::string, std::string, std::string> S3AccessKeyTuple;

private:
SignedUrlCache() = default;

std::mutex d_cache_lock_mutex;

std::map<std::string, std::shared_ptr<http::EffectiveUrl>> d_signed_urls;

std::map<std::string, std::string> d_href_to_s3credentials_cache;
std::map<std::string, std::string> d_href_to_s3_cache;

std::shared_ptr<S3AccessKeyTuple> get_s3credentials_from_endpoint(std::string const &s3credentials_url);
static std::shared_ptr<S3AccessKeyTuple> extract_s3_credentials_from_response_json(std::string const &s3credentials_json_string);

std::map<std::string, std::shared_ptr<S3AccessKeyTuple>> d_s3credentials_cache;
std::shared_ptr<S3AccessKeyTuple> retrieve_cached_s3credentials(std::string const &url_key);
static bool is_timestamp_after_now(std::string const &timestamp);

// URLs that match are not cached.
std::unique_ptr<BESRegex> d_skip_regex = nullptr;

int d_enabled = -1;

std::shared_ptr<EffectiveUrl> sign_url(std::string const &s3_url,
std::shared_ptr<S3AccessKeyTuple> const s3_access_key_tuple);
std::shared_ptr<EffectiveUrl> get_cached_signed_url(std::string const &url_key);

void set_skip_regex();

bool is_enabled();

friend class SignedUrlCacheTest;

public:
/** @brief Get the singleton SignedUrlCache instance.
*
* This static method returns the instance of this singleton class.
* The implementation will only build one instance of SignedUrlCache and
* thereafter return a pointer to that instance.
*
* Thread safe with C++-11 and greater.
*
* @return A pointer to the SignedUrlCache singleton
*/
static SignedUrlCache *TheCache() {
// Create a local static object the first time the function is called
static SignedUrlCache instance;
return &instance;
}

SignedUrlCache(const SignedUrlCache &src) = delete;
SignedUrlCache &operator=(const SignedUrlCache &rhs) = delete;

~SignedUrlCache() override = default;

void cache_signed_url_components(const std::string &key_href_url, const std::string &s3_url, const std::string &s3credentials_url);
std::pair<std::string, std::string> retrieve_cached_signed_url_components(const std::string &key_href_url) const;
std::shared_ptr<EffectiveUrl> get_signed_url(std::shared_ptr<url> source_url);

void dump(std::ostream &strm) const override;

std::string dump() const {
std::stringstream sstrm;
dump(sstrm);
return sstrm.str();
}
};

} // namespace http

#endif // _bes_http_SignedUrlCache_h_

1 change: 1 addition & 0 deletions http/unit-tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/CurlUtilsTest
/CurlSListTest
/EffectiveUrlCacheTest
/SignedUrlCacheTest
/HttpUrlTest
/HttpErrorTest
/AllowedHostsTest
Expand Down
5 changes: 4 additions & 1 deletion http/unit-tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bes_ngap_s3_creds.conf: bes_ngap_s3_creds.conf.in $(top_srcdir)/configure.ac

if CPPUNIT

UNIT_TESTS = HttpUtilsTest HttpErrorTest RemoteResourceTest EffectiveUrlCacheTest HttpUrlTest \
UNIT_TESTS = HttpUtilsTest HttpErrorTest RemoteResourceTest EffectiveUrlCacheTest HttpUrlTest SignedUrlCacheTest \
AllowedHostsTest awsv4_test CurlUtilsTest CurlSListTest

# CredentialsManagerTest was removed because it was testing our S3 signing code and
Expand Down Expand Up @@ -122,6 +122,9 @@ CurlUtilsTest_LDADD = $(LIBADD)
EffectiveUrlCacheTest_SOURCES = EffectiveUrlCacheTest.cc
EffectiveUrlCacheTest_LDADD = $(LIBADD)

SignedUrlCacheTest_SOURCES = SignedUrlCacheTest.cc
SignedUrlCacheTest_LDADD = $(LIBADD)

HttpUrlTest_SOURCES = HttpUrlTest.cc
HttpUrlTest_LDADD = $(LIBADD)

Expand Down
Loading