You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/11/24 11:01:54 UTC

[GitHub] [nifi-minifi-cpp] lordgamez commented on a change in pull request #939: MINIFICPP-1409 Add default credentials provider chain support to AWS authentication

lordgamez commented on a change in pull request #939:
URL: https://github.com/apache/nifi-minifi-cpp/pull/939#discussion_r529458199



##########
File path: extensions/aws/processors/PutS3Object.cpp
##########
@@ -220,57 +227,29 @@ minifi::utils::optional<Aws::Auth::AWSCredentials> PutS3Object::getAWSCredential
   return minifi::utils::nullopt;
 }
 
-minifi::utils::optional<Aws::Auth::AWSCredentials> PutS3Object::getAWSCredentialsFromProperties(
-    const std::shared_ptr<core::ProcessContext> &context,
-    const std::shared_ptr<core::FlowFile> &flow_file) const {
-  std::string access_key;
-  context->getProperty(AccessKey, access_key, flow_file);
-  std::string secret_key;
-  context->getProperty(SecretKey, secret_key, flow_file);
-  if (!access_key.empty() && !secret_key.empty()) {
-    Aws::Auth::AWSCredentials creds(access_key, secret_key);
-    return minifi::utils::make_optional<Aws::Auth::AWSCredentials>(creds);
-  }
-  return minifi::utils::nullopt;
-}
-
-minifi::utils::optional<Aws::Auth::AWSCredentials> PutS3Object::getAWSCredentialsFromFile(const std::shared_ptr<core::ProcessContext> &context) const {
-  std::string credential_file;
-  if (context->getProperty(CredentialsFile.getName(), credential_file) && !credential_file.empty()) {
-    auto properties = std::make_shared<minifi::Properties>();
-    properties->loadConfigureFile(credential_file.c_str());
-    std::string access_key;
-    std::string secret_key;
-    if (properties->getString("accessKey", access_key) && !access_key.empty() && properties->getString("secretKey", secret_key) && !secret_key.empty()) {
-      Aws::Auth::AWSCredentials creds(access_key, secret_key);
-      return minifi::utils::make_optional<Aws::Auth::AWSCredentials>(creds);
-    }
-  }
-  return minifi::utils::nullopt;
-}
-
 minifi::utils::optional<Aws::Auth::AWSCredentials> PutS3Object::getAWSCredentials(
     const std::shared_ptr<core::ProcessContext> &context,
-    const std::shared_ptr<core::FlowFile> &flow_file) const {
-  auto prop_cred = getAWSCredentialsFromProperties(context, flow_file);
-  if (prop_cred) {
-    logger_->log_info("AWS Credentials successfully set from properties");
-    return prop_cred.value();
-  }
-
-  auto file_cred = getAWSCredentialsFromFile(context);
-  if (file_cred) {
-    logger_->log_info("AWS Credentials successfully set from file");
-    return file_cred.value();
-  }
-
+    const std::shared_ptr<core::FlowFile> &flow_file) {

Review comment:
       We are now using the new AwsCredentialsProvider class to retrieve the credentials if no controller service is used. This provider is a member which is changed in this function so it cannot be const anymore.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org