-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
implement FDBAWSCredentialsProviderChain(release-7.1) #10880
Draft
hfu94
wants to merge
3
commits into
apple:release-7.1
Choose a base branch
from
hfu94:chain71
base: release-7.1
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* FDBAWSCredentialsProviderChain.cpp | ||
* | ||
* This source file is part of the FoundationDB open source project | ||
* | ||
* Copyright 2013-2022 Apple Inc. and the FoundationDB project authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "fdbclient/FDBAWSCredentialsProviderChain.h" | ||
|
||
#ifdef BUILD_AWS_BACKUP | ||
|
||
#include "aws/core/auth/STSCredentialsProvider.h" | ||
#include "aws/core/auth/SSOCredentialsProvider.h" | ||
#include "aws/identity-management/auth/STSProfileCredentialsProvider.h" | ||
#include "aws/core/platform/Environment.h" | ||
#include "aws/core/utils/memory/AWSMemory.h" | ||
#include "aws/core/utils/StringUtils.h" | ||
#include "aws/core/utils/logging/LogMacros.h" | ||
|
||
static const char AWS_ECS_CONTAINER_CREDENTIALS_RELATIVE_URI[] = "AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"; | ||
static const char AWS_ECS_CONTAINER_CREDENTIALS_FULL_URI[] = "AWS_CONTAINER_CREDENTIALS_FULL_URI"; | ||
static const char AWS_ECS_CONTAINER_AUTHORIZATION_TOKEN[] = "AWS_CONTAINER_AUTHORIZATION_TOKEN"; | ||
static const char AWS_EC2_METADATA_DISABLED[] = "AWS_EC2_METADATA_DISABLED"; | ||
static const char DefaultCredentialsProviderChainTag[] = "DefaultAWSCredentialsProviderChain"; | ||
|
||
// this method is copied from | ||
// https://github.com/aws/aws-sdk-cpp/blob/98a87de4e2e532cc88e527a27fbdf110d9375e6b/src/aws-cpp-sdk-core/source/auth/AWSCredentialsProviderChain.cpp#L36 | ||
|
||
FDBAWSCredentialsProviderChain::FDBAWSCredentialsProviderChain() : Aws::Auth::AWSCredentialsProviderChain() { | ||
AddProvider(Aws::MakeShared<Aws::Auth::EnvironmentAWSCredentialsProvider>(DefaultCredentialsProviderChainTag)); | ||
AddProvider( | ||
Aws::MakeShared<Aws::Auth::ProfileConfigFileAWSCredentialsProvider>(DefaultCredentialsProviderChainTag)); | ||
AddProvider(Aws::MakeShared<Aws::Auth::ProcessCredentialsProvider>(DefaultCredentialsProviderChainTag)); | ||
// added line below to support assume role and profile | ||
AddProvider(Aws::MakeShared<Aws::Auth::STSProfileCredentialsProvider>(DefaultCredentialsProviderChainTag)); | ||
AddProvider( | ||
Aws::MakeShared<Aws::Auth::STSAssumeRoleWebIdentityCredentialsProvider>(DefaultCredentialsProviderChainTag)); | ||
AddProvider(Aws::MakeShared<Aws::Auth::SSOCredentialsProvider>(DefaultCredentialsProviderChainTag)); | ||
|
||
// ECS TaskRole Credentials only available when ENVIRONMENT VARIABLE is set | ||
const auto relativeUri = Aws::Environment::GetEnv(AWS_ECS_CONTAINER_CREDENTIALS_RELATIVE_URI); | ||
AWS_LOGSTREAM_DEBUG(DefaultCredentialsProviderChainTag, | ||
"The environment variable value " << AWS_ECS_CONTAINER_CREDENTIALS_RELATIVE_URI << " is " | ||
<< relativeUri); | ||
|
||
const auto absoluteUri = Aws::Environment::GetEnv(AWS_ECS_CONTAINER_CREDENTIALS_FULL_URI); | ||
AWS_LOGSTREAM_DEBUG(DefaultCredentialsProviderChainTag, | ||
"The environment variable value " << AWS_ECS_CONTAINER_CREDENTIALS_FULL_URI << " is " | ||
<< absoluteUri); | ||
|
||
const auto ec2MetadataDisabled = Aws::Environment::GetEnv(AWS_EC2_METADATA_DISABLED); | ||
AWS_LOGSTREAM_DEBUG(DefaultCredentialsProviderChainTag, | ||
"The environment variable value " << AWS_EC2_METADATA_DISABLED << " is " | ||
<< ec2MetadataDisabled); | ||
|
||
if (!relativeUri.empty()) { | ||
AddProvider(Aws::MakeShared<Aws::Auth::TaskRoleCredentialsProvider>(DefaultCredentialsProviderChainTag, | ||
relativeUri.c_str())); | ||
AWS_LOGSTREAM_INFO(DefaultCredentialsProviderChainTag, | ||
"Added ECS metadata service credentials provider with relative path: [" | ||
<< relativeUri << "] to the provider chain."); | ||
} else if (!absoluteUri.empty()) { | ||
const auto token = Aws::Environment::GetEnv(AWS_ECS_CONTAINER_AUTHORIZATION_TOKEN); | ||
AddProvider(Aws::MakeShared<Aws::Auth::TaskRoleCredentialsProvider>( | ||
DefaultCredentialsProviderChainTag, absoluteUri.c_str(), token.c_str())); | ||
|
||
// DO NOT log the value of the authorization token for security purposes. | ||
AWS_LOGSTREAM_INFO(DefaultCredentialsProviderChainTag, | ||
"Added ECS credentials provider with URI: [" | ||
<< absoluteUri << "] to the provider chain with a" | ||
<< (token.empty() ? "n empty " : " non-empty ") << "authorization token."); | ||
} else if (Aws::Utils::StringUtils::ToLower(ec2MetadataDisabled.c_str()) != "true") { | ||
AddProvider(Aws::MakeShared<Aws::Auth::InstanceProfileCredentialsProvider>(DefaultCredentialsProviderChainTag)); | ||
AWS_LOGSTREAM_INFO(DefaultCredentialsProviderChainTag, | ||
"Added EC2 metadata service credentials provider to the provider chain."); | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* FDBAWSCredentialsProviderChain.h | ||
* | ||
* This source file is part of the FoundationDB open source project | ||
* | ||
* Copyright 2013-2022 Apple Inc. and the FoundationDB project authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifdef BUILD_AWS_BACKUP | ||
|
||
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. Add something like 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. thanks, will update the PR once I discuss testing with @johscheuer |
||
#include "aws/core/Aws.h" | ||
#include "aws/core/auth/AWSCredentialsProviderChain.h" | ||
|
||
class FDBAWSCredentialsProviderChain : public Aws::Auth::AWSCredentialsProviderChain { | ||
public: | ||
FDBAWSCredentialsProviderChain(); | ||
}; | ||
|
||
#endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Instead of here, they should be added to where
FDBCLIENT_SRCS
is defined.