-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(clp-json): Add session token support for presigned URL authentication. #680
Changes from 3 commits
ce9e38d
0637d46
1415789
c274780
a46fd09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -12,6 +12,7 @@ constexpr std::string_view cXAmzAlgorithm{"X-Amz-Algorithm"}; | |||||
constexpr std::string_view cXAmzCredential{"X-Amz-Credential"}; | ||||||
constexpr std::string_view cXAmzDate{"X-Amz-Date"}; | ||||||
constexpr std::string_view cXAmzExpires{"X-Amz-Expires"}; | ||||||
constexpr std::string_view cAmzSecurityToken{"X-Amz-Security-Token"}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing an "X"?
Suggested change
|
||||||
constexpr std::string_view cXAmzSignature{"X-Amz-Signature"}; | ||||||
constexpr std::string_view cXAmzSignedHeaders{"X-Amz-SignedHeaders"}; | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
#include "ReaderUtils.hpp" | ||
|
||
#include <exception> | ||
#include <string> | ||
#include <string_view> | ||
#include <unordered_map> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. didn't see this used in the file. Is it intended? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope -- leftover from when I was going to pass the token as an http header. Will delete. |
||
|
||
#include <spdlog/spdlog.h> | ||
|
||
#include "../clp/aws/AwsAuthenticationSigner.hpp" | ||
#include "../clp/CurlDownloadHandler.hpp" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. intended? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also a leftover. Will delete. |
||
#include "../clp/FileReader.hpp" | ||
#include "../clp/NetworkReader.hpp" | ||
#include "../clp/ReaderInterface.hpp" | ||
|
@@ -164,8 +167,17 @@ bool try_sign_url(std::string& url) { | |
); | ||
return false; | ||
} | ||
std::optional<std::string> optional_aws_session_token{std::nullopt}; | ||
auto const aws_session_token = std::getenv(cAwsSessionTokenEnvVar); | ||
if (nullptr != aws_session_token) { | ||
optional_aws_session_token = std::string{aws_session_token}; | ||
} | ||
|
||
clp::aws::AwsAuthenticationSigner signer{aws_access_key, aws_secret_access_key}; | ||
clp::aws::AwsAuthenticationSigner signer{ | ||
aws_access_key, | ||
aws_secret_access_key, | ||
optional_aws_session_token | ||
}; | ||
|
||
try { | ||
clp::aws::S3Url s3_url{url}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will be the behavior is m_session_token.has_value() == false?
I assume session_token_parameter will have an empty string as value hence the extra {} will evaluate to nothing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally feel it might be better to append session_token_parameter explicitly, since te number of {}={} already make the original fmt::format pretty hard to decipher (I had to count by myself when making the change), but ulitimately it's up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Will refactor to append session token explicitly.