From 701d3cdf9a60eea036449559148c6cabdb359057 Mon Sep 17 00:00:00 2001 From: Bassam Ojeil Date: Mon, 8 Feb 2021 13:54:15 -0800 Subject: [PATCH 1/3] Move third party identity C++ api out of experimental namespace This PR is a continuation of: https://github.com/grpc/grpc/pull/25304 --- include/grpcpp/security/credentials.h | 12 ++++++------ src/cpp/client/secure_credentials.cc | 4 ---- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/include/grpcpp/security/credentials.h b/include/grpcpp/security/credentials.h index 98b5d9a42a1..1b1f994c1a9 100644 --- a/include/grpcpp/security/credentials.h +++ b/include/grpcpp/security/credentials.h @@ -277,6 +277,12 @@ class MetadataCredentialsPlugin { std::shared_ptr MetadataCredentialsFromPlugin( std::unique_ptr plugin); +/// Builds External Account credentials. +/// json_string is the JSON string containing the credentials options. +/// scopes contains the scopes to be binded with the credentials. +std::shared_ptr ExternalAccountCredentials( + const grpc::string& json_string, const std::vector& scopes); + namespace experimental { /// Options for creating STS Oauth Token Exchange credentials following the IETF @@ -307,12 +313,6 @@ grpc::Status StsCredentialsOptionsFromEnv(StsCredentialsOptions* options); std::shared_ptr StsCredentials( const StsCredentialsOptions& options); -/// Builds External Account credentials. -/// json_string is the JSON string containing the credentials options. -/// scopes contains the scopes to be binded with the credentials. -std::shared_ptr ExternalAccountCredentials( - const grpc::string& json_string, const std::vector& scopes); - std::shared_ptr MetadataCredentialsFromPlugin( std::unique_ptr plugin, grpc_security_level min_security_level); diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc index 4facd2b821b..fd9cd4ca8b2 100644 --- a/src/cpp/client/secure_credentials.cc +++ b/src/cpp/client/secure_credentials.cc @@ -109,8 +109,6 @@ std::shared_ptr GoogleDefaultCredentials() { grpc_google_default_credentials_create(nullptr)); } -namespace experimental { - std::shared_ptr ExternalAccountCredentials( const grpc::string& json_string, const std::vector& scopes) { grpc::GrpcLibraryCodegen init; // To call grpc_init(). @@ -118,8 +116,6 @@ std::shared_ptr ExternalAccountCredentials( json_string.c_str(), absl::StrJoin(scopes, ",").c_str())); } -} // namespace experimental - // Builds SSL Credentials given SSL specific options std::shared_ptr SslCredentials( const SslCredentialsOptions& options) { From a8e061bf8853e52f8bb332e50fddb6e5a914e02c Mon Sep 17 00:00:00 2001 From: Bassam Ojeil Date: Mon, 8 Feb 2021 14:22:04 -0800 Subject: [PATCH 2/3] Removes experimental namespace from ExternalAccountCredentials tests. --- test/cpp/client/credentials_test.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc index 518a90a61f0..a061eb496e1 100644 --- a/test/cpp/client/credentials_test.cc +++ b/test/cpp/client/credentials_test.cc @@ -110,7 +110,7 @@ TEST(CredentialsTest, ExternalAccountCredentials) { "\"access_token\"}},\"quota_project_id\":\"quota_" "project_id\",\"client_id\":\"client_id\",\"client_secret\":\"client_" "secret\"}"); - auto url_creds = grpc::experimental::ExternalAccountCredentials( + auto url_creds = grpc::ExternalAccountCredentials( url_options_string, {"scope1", "scope2"}); EXPECT_TRUE(url_creds != nullptr); // file credentials @@ -123,7 +123,7 @@ TEST(CredentialsTest, ExternalAccountCredentials) { "\"quota_project_id\":\"quota_" "project_id\",\"client_id\":\"client_id\",\"client_secret\":\"client_" "secret\"}"); - auto file_creds = grpc::experimental::ExternalAccountCredentials( + auto file_creds = grpc::ExternalAccountCredentials( file_options_string, {"scope1", "scope2"}); EXPECT_TRUE(file_creds != nullptr); // aws credentials @@ -139,7 +139,7 @@ TEST(CredentialsTest, ExternalAccountCredentials) { "\"quota_project_id\":\"quota_" "project_id\",\"client_id\":\"client_id\",\"client_secret\":\"client_" "secret\"}"); - auto aws_creds = grpc::experimental::ExternalAccountCredentials( + auto aws_creds = grpc::ExternalAccountCredentials( aws_options_string, {"scope1", "scope2"}); EXPECT_TRUE(aws_creds != nullptr); } From 33b80f16ec0c6c8792d2e1f301ac2416c6cd6312 Mon Sep 17 00:00:00 2001 From: bojeil-google Date: Mon, 8 Feb 2021 15:42:40 -0800 Subject: [PATCH 3/3] Applies clang_format_code.sh to address sanity check tests. --- test/cpp/client/credentials_test.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc index a061eb496e1..122ba929274 100644 --- a/test/cpp/client/credentials_test.cc +++ b/test/cpp/client/credentials_test.cc @@ -110,8 +110,8 @@ TEST(CredentialsTest, ExternalAccountCredentials) { "\"access_token\"}},\"quota_project_id\":\"quota_" "project_id\",\"client_id\":\"client_id\",\"client_secret\":\"client_" "secret\"}"); - auto url_creds = grpc::ExternalAccountCredentials( - url_options_string, {"scope1", "scope2"}); + auto url_creds = grpc::ExternalAccountCredentials(url_options_string, + {"scope1", "scope2"}); EXPECT_TRUE(url_creds != nullptr); // file credentials std::string file_options_string( @@ -123,8 +123,8 @@ TEST(CredentialsTest, ExternalAccountCredentials) { "\"quota_project_id\":\"quota_" "project_id\",\"client_id\":\"client_id\",\"client_secret\":\"client_" "secret\"}"); - auto file_creds = grpc::ExternalAccountCredentials( - file_options_string, {"scope1", "scope2"}); + auto file_creds = grpc::ExternalAccountCredentials(file_options_string, + {"scope1", "scope2"}); EXPECT_TRUE(file_creds != nullptr); // aws credentials std::string aws_options_string( @@ -139,8 +139,8 @@ TEST(CredentialsTest, ExternalAccountCredentials) { "\"quota_project_id\":\"quota_" "project_id\",\"client_id\":\"client_id\",\"client_secret\":\"client_" "secret\"}"); - auto aws_creds = grpc::ExternalAccountCredentials( - aws_options_string, {"scope1", "scope2"}); + auto aws_creds = grpc::ExternalAccountCredentials(aws_options_string, + {"scope1", "scope2"}); EXPECT_TRUE(aws_creds != nullptr); }