Skip to content

Commit a97161f

Browse files
docs: add warning about loading unvalidated credentials
1 parent 4e51377 commit a97161f

173 files changed

Lines changed: 3460 additions & 321 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

google-ads-marketing_platform-admin-v1alpha/lib/google/ads/marketing_platform/admin/v1alpha/marketingplatform_admin_service/client.rb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,8 +694,6 @@ def set_property_service_level request, options = nil
694694
# @return [::String,nil]
695695
# @!attribute [rw] credentials
696696
# Credentials to send with calls. You may provide any of the following types:
697-
# * (`String`) The path to a service account key file in JSON format
698-
# * (`Hash`) A service account key as a Hash
699697
# * (`Google::Auth::Credentials`) A googleauth credentials object
700698
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
701699
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
@@ -704,7 +702,26 @@ def set_property_service_level request, options = nil
704702
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
705703
# * (`nil`) indicating no credentials
706704
#
707-
# Warning: If you accept a credential configuration (JSON file or Hash) from an
705+
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
706+
# is deprecated. Providing an unvalidated credential configuration to
707+
# Google APIs can compromise the security of your systems and data.
708+
#
709+
# @example
710+
#
711+
# # The recommended way to provide credentials is to use the `make_creds` method
712+
# # on the appropriate credentials class for your environment.
713+
#
714+
# require "googleauth"
715+
#
716+
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
717+
# json_key_io: ::File.open("/path/to/keyfile.json")
718+
# )
719+
#
720+
# client = ::Google::Ads::MarketingPlatform::Admin::V1alpha::MarketingplatformAdminService::Client.new do |config|
721+
# config.credentials = credentials
722+
# end
723+
#
724+
# @note Warning: If you accept a credential configuration (JSON file or Hash) from an
708725
# external source for authentication to Google Cloud, you must validate it before
709726
# providing it to a Google API client library. Providing an unvalidated credential
710727
# configuration to Google APIs can compromise the security of your systems and data.

google-ads-marketing_platform-admin-v1alpha/test/google/ads/marketing_platform/admin/v1alpha/marketingplatform_admin_service_test.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,4 +386,24 @@ def test_configure
386386
assert_same block_config, config
387387
assert_kind_of ::Google::Ads::MarketingPlatform::Admin::V1alpha::MarketingplatformAdminService::Client::Configuration, config
388388
end
389+
390+
def test_credentials
391+
key = OpenSSL::PKey::RSA.new 2048
392+
cred_json = {
393+
"private_key" => key.to_pem,
394+
"client_email" => "app@developer.gserviceaccount.com",
395+
"type" => "service_account"
396+
}
397+
key_file = StringIO.new cred_json.to_json
398+
creds = Google::Auth::ServiceAccountCredentials.make_creds({ json_key_io: key_file })
399+
400+
dummy_stub = ClientStub.new nil, nil
401+
Gapic::ServiceStub.stub :new, dummy_stub do
402+
client = ::Google::Ads::MarketingPlatform::Admin::V1alpha::MarketingplatformAdminService::Client.new do |config|
403+
config.credentials = creds
404+
end
405+
assert_kind_of ::Google::Ads::MarketingPlatform::Admin::V1alpha::MarketingplatformAdminService::Client, client
406+
assert_equal creds, client.configure.credentials
407+
end
408+
end
389409
end

google-analytics-admin-v1alpha/lib/google/analytics/admin/v1alpha/analytics_admin_service/client.rb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14482,8 +14482,6 @@ def get_reporting_identity_settings request, options = nil
1448214482
# @return [::String,nil]
1448314483
# @!attribute [rw] credentials
1448414484
# Credentials to send with calls. You may provide any of the following types:
14485-
# * (`String`) The path to a service account key file in JSON format
14486-
# * (`Hash`) A service account key as a Hash
1448714485
# * (`Google::Auth::Credentials`) A googleauth credentials object
1448814486
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
1448914487
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
@@ -14492,7 +14490,26 @@ def get_reporting_identity_settings request, options = nil
1449214490
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
1449314491
# * (`nil`) indicating no credentials
1449414492
#
14495-
# Warning: If you accept a credential configuration (JSON file or Hash) from an
14493+
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
14494+
# is deprecated. Providing an unvalidated credential configuration to
14495+
# Google APIs can compromise the security of your systems and data.
14496+
#
14497+
# @example
14498+
#
14499+
# # The recommended way to provide credentials is to use the `make_creds` method
14500+
# # on the appropriate credentials class for your environment.
14501+
#
14502+
# require "googleauth"
14503+
#
14504+
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
14505+
# json_key_io: ::File.open("/path/to/keyfile.json")
14506+
# )
14507+
#
14508+
# client = ::Google::Analytics::Admin::V1alpha::AnalyticsAdminService::Client.new do |config|
14509+
# config.credentials = credentials
14510+
# end
14511+
#
14512+
# @note Warning: If you accept a credential configuration (JSON file or Hash) from an
1449614513
# external source for authentication to Google Cloud, you must validate it before
1449714514
# providing it to a Google API client library. Providing an unvalidated credential
1449814515
# configuration to Google APIs can compromise the security of your systems and data.

google-analytics-admin-v1alpha/test/google/analytics/admin/v1alpha/analytics_admin_service_test.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9439,4 +9439,24 @@ def test_configure
94399439
assert_same block_config, config
94409440
assert_kind_of ::Google::Analytics::Admin::V1alpha::AnalyticsAdminService::Client::Configuration, config
94419441
end
9442+
9443+
def test_credentials
9444+
key = OpenSSL::PKey::RSA.new 2048
9445+
cred_json = {
9446+
"private_key" => key.to_pem,
9447+
"client_email" => "app@developer.gserviceaccount.com",
9448+
"type" => "service_account"
9449+
}
9450+
key_file = StringIO.new cred_json.to_json
9451+
creds = Google::Auth::ServiceAccountCredentials.make_creds({ json_key_io: key_file })
9452+
9453+
dummy_stub = ClientStub.new nil, nil
9454+
Gapic::ServiceStub.stub :new, dummy_stub do
9455+
client = ::Google::Analytics::Admin::V1alpha::AnalyticsAdminService::Client.new do |config|
9456+
config.credentials = creds
9457+
end
9458+
assert_kind_of ::Google::Analytics::Admin::V1alpha::AnalyticsAdminService::Client, client
9459+
assert_equal creds, client.configure.credentials
9460+
end
9461+
end
94429462
end

google-analytics-data-v1beta/lib/google/analytics/data/v1beta/analytics_data/client.rb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,8 +1577,6 @@ def list_audience_exports request, options = nil
15771577
# @return [::String,nil]
15781578
# @!attribute [rw] credentials
15791579
# Credentials to send with calls. You may provide any of the following types:
1580-
# * (`String`) The path to a service account key file in JSON format
1581-
# * (`Hash`) A service account key as a Hash
15821580
# * (`Google::Auth::Credentials`) A googleauth credentials object
15831581
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
15841582
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
@@ -1587,7 +1585,26 @@ def list_audience_exports request, options = nil
15871585
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
15881586
# * (`nil`) indicating no credentials
15891587
#
1590-
# Warning: If you accept a credential configuration (JSON file or Hash) from an
1588+
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
1589+
# is deprecated. Providing an unvalidated credential configuration to
1590+
# Google APIs can compromise the security of your systems and data.
1591+
#
1592+
# @example
1593+
#
1594+
# # The recommended way to provide credentials is to use the `make_creds` method
1595+
# # on the appropriate credentials class for your environment.
1596+
#
1597+
# require "googleauth"
1598+
#
1599+
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
1600+
# json_key_io: ::File.open("/path/to/keyfile.json")
1601+
# )
1602+
#
1603+
# client = ::Google::Analytics::Data::V1beta::AnalyticsData::Client.new do |config|
1604+
# config.credentials = credentials
1605+
# end
1606+
#
1607+
# @note Warning: If you accept a credential configuration (JSON file or Hash) from an
15911608
# external source for authentication to Google Cloud, you must validate it before
15921609
# providing it to a Google API client library. Providing an unvalidated credential
15931610
# configuration to Google APIs can compromise the security of your systems and data.

google-analytics-data-v1beta/lib/google/analytics/data/v1beta/analytics_data/operations.rb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,6 @@ def wait_operation request, options = nil
642642
# @return [::String,nil]
643643
# @!attribute [rw] credentials
644644
# Credentials to send with calls. You may provide any of the following types:
645-
# * (`String`) The path to a service account key file in JSON format
646-
# * (`Hash`) A service account key as a Hash
647645
# * (`Google::Auth::Credentials`) A googleauth credentials object
648646
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
649647
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
@@ -652,7 +650,26 @@ def wait_operation request, options = nil
652650
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
653651
# * (`nil`) indicating no credentials
654652
#
655-
# Warning: If you accept a credential configuration (JSON file or Hash) from an
653+
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
654+
# is deprecated. Providing an unvalidated credential configuration to
655+
# Google APIs can compromise the security of your systems and data.
656+
#
657+
# @example
658+
#
659+
# # The recommended way to provide credentials is to use the `make_creds` method
660+
# # on the appropriate credentials class for your environment.
661+
#
662+
# require "googleauth"
663+
#
664+
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
665+
# json_key_io: ::File.open("/path/to/keyfile.json")
666+
# )
667+
#
668+
# client = ::Google::Longrunning::Operations::Client.new do |config|
669+
# config.credentials = credentials
670+
# end
671+
#
672+
# @note Warning: If you accept a credential configuration (JSON file or Hash) from an
656673
# external source for authentication to Google Cloud, you must validate it before
657674
# providing it to a Google API client library. Providing an unvalidated credential
658675
# configuration to Google APIs can compromise the security of your systems and data.

google-analytics-data-v1beta/test/google/analytics/data/v1beta/analytics_data_test.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,26 @@ def test_configure
822822
assert_kind_of ::Google::Analytics::Data::V1beta::AnalyticsData::Client::Configuration, config
823823
end
824824

825+
def test_credentials
826+
key = OpenSSL::PKey::RSA.new 2048
827+
cred_json = {
828+
"private_key" => key.to_pem,
829+
"client_email" => "app@developer.gserviceaccount.com",
830+
"type" => "service_account"
831+
}
832+
key_file = StringIO.new cred_json.to_json
833+
creds = Google::Auth::ServiceAccountCredentials.make_creds({ json_key_io: key_file })
834+
835+
dummy_stub = ClientStub.new nil, nil
836+
Gapic::ServiceStub.stub :new, dummy_stub do
837+
client = ::Google::Analytics::Data::V1beta::AnalyticsData::Client.new do |config|
838+
config.credentials = creds
839+
end
840+
assert_kind_of ::Google::Analytics::Data::V1beta::AnalyticsData::Client, client
841+
assert_equal creds, client.configure.credentials
842+
end
843+
end
844+
825845
def test_operations_client
826846
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
827847

google-apps-events-subscriptions-v1/lib/google/apps/events/subscriptions/v1/subscriptions_service/client.rb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,6 @@ def reactivate_subscription request, options = nil
880880
# @return [::String,nil]
881881
# @!attribute [rw] credentials
882882
# Credentials to send with calls. You may provide any of the following types:
883-
# * (`String`) The path to a service account key file in JSON format
884-
# * (`Hash`) A service account key as a Hash
885883
# * (`Google::Auth::Credentials`) A googleauth credentials object
886884
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
887885
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
@@ -890,7 +888,26 @@ def reactivate_subscription request, options = nil
890888
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
891889
# * (`nil`) indicating no credentials
892890
#
893-
# Warning: If you accept a credential configuration (JSON file or Hash) from an
891+
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
892+
# is deprecated. Providing an unvalidated credential configuration to
893+
# Google APIs can compromise the security of your systems and data.
894+
#
895+
# @example
896+
#
897+
# # The recommended way to provide credentials is to use the `make_creds` method
898+
# # on the appropriate credentials class for your environment.
899+
#
900+
# require "googleauth"
901+
#
902+
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
903+
# json_key_io: ::File.open("/path/to/keyfile.json")
904+
# )
905+
#
906+
# client = ::Google::Apps::Events::Subscriptions::V1::SubscriptionsService::Client.new do |config|
907+
# config.credentials = credentials
908+
# end
909+
#
910+
# @note Warning: If you accept a credential configuration (JSON file or Hash) from an
894911
# external source for authentication to Google Cloud, you must validate it before
895912
# providing it to a Google API client library. Providing an unvalidated credential
896913
# configuration to Google APIs can compromise the security of your systems and data.

google-apps-events-subscriptions-v1/lib/google/apps/events/subscriptions/v1/subscriptions_service/operations.rb

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,6 @@ def wait_operation request, options = nil
643643
# @return [::String,nil]
644644
# @!attribute [rw] credentials
645645
# Credentials to send with calls. You may provide any of the following types:
646-
# * (`String`) The path to a service account key file in JSON format
647-
# * (`Hash`) A service account key as a Hash
648646
# * (`Google::Auth::Credentials`) A googleauth credentials object
649647
# (see the [googleauth docs](https://rubydoc.info/gems/googleauth/Google/Auth/Credentials))
650648
# * (`Signet::OAuth2::Client`) A signet oauth2 client object
@@ -653,7 +651,26 @@ def wait_operation request, options = nil
653651
# * (`GRPC::Core::ChannelCredentials`) a gRPC credentails object
654652
# * (`nil`) indicating no credentials
655653
#
656-
# Warning: If you accept a credential configuration (JSON file or Hash) from an
654+
# @note Warning: Passing a `String` to a keyfile path or a `Hash` of credentials
655+
# is deprecated. Providing an unvalidated credential configuration to
656+
# Google APIs can compromise the security of your systems and data.
657+
#
658+
# @example
659+
#
660+
# # The recommended way to provide credentials is to use the `make_creds` method
661+
# # on the appropriate credentials class for your environment.
662+
#
663+
# require "googleauth"
664+
#
665+
# credentials = ::Google::Auth::ServiceAccountCredentials.make_creds(
666+
# json_key_io: ::File.open("/path/to/keyfile.json")
667+
# )
668+
#
669+
# client = ::Google::Longrunning::Operations::Client.new do |config|
670+
# config.credentials = credentials
671+
# end
672+
#
673+
# @note Warning: If you accept a credential configuration (JSON file or Hash) from an
657674
# external source for authentication to Google Cloud, you must validate it before
658675
# providing it to a Google API client library. Providing an unvalidated credential
659676
# configuration to Google APIs can compromise the security of your systems and data.

google-apps-events-subscriptions-v1/test/google/apps/events/subscriptions/v1/subscriptions_service_test.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,26 @@ def test_configure
471471
assert_kind_of ::Google::Apps::Events::Subscriptions::V1::SubscriptionsService::Client::Configuration, config
472472
end
473473

474+
def test_credentials
475+
key = OpenSSL::PKey::RSA.new 2048
476+
cred_json = {
477+
"private_key" => key.to_pem,
478+
"client_email" => "app@developer.gserviceaccount.com",
479+
"type" => "service_account"
480+
}
481+
key_file = StringIO.new cred_json.to_json
482+
creds = Google::Auth::ServiceAccountCredentials.make_creds({ json_key_io: key_file })
483+
484+
dummy_stub = ClientStub.new nil, nil
485+
Gapic::ServiceStub.stub :new, dummy_stub do
486+
client = ::Google::Apps::Events::Subscriptions::V1::SubscriptionsService::Client.new do |config|
487+
config.credentials = creds
488+
end
489+
assert_kind_of ::Google::Apps::Events::Subscriptions::V1::SubscriptionsService::Client, client
490+
assert_equal creds, client.configure.credentials
491+
end
492+
end
493+
474494
def test_operations_client
475495
grpc_channel = GRPC::Core::Channel.new "localhost:8888", nil, :this_channel_is_insecure
476496

0 commit comments

Comments
 (0)