Skip to content

Commit 1529302

Browse files
authored
chore: Add warnings to users about using credentials from external sources (#1619)
* chore: Update README with warnings about externally source credentials * chore: Update method javadocs with warning * chore: Add warnings to all fromStream() calls * chore: Remove warning from UserCredentials and ServiceAccounJwtAccessCredentials
1 parent b4254fa commit 1529302

5 files changed

+61
-0
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ credentials. This artifact depends on the App Engine SDK.
1616
- [*google-auth-library-oauth2-http*](#google-auth-library-oauth2-http): contains a wide variety of
1717
credentials as well as utility methods to create them and to get Application Default Credentials
1818

19+
> ⚠️ Important: If you accept a credential configuration (credential JSON/File/Stream) from an external source for
20+
authentication to Google Cloud Platform, you must validate it before providing it to any Google API or library. Providing
21+
an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more
22+
information, refer to [documentation](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
23+
1924
**Table of contents:**
2025

2126

oauth2_http/java/com/google/auth/oauth2/ExternalAccountAuthorizedUserCredentials.java

+14
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ private ExternalAccountAuthorizedUserCredentials(Builder builder) {
127127
/**
128128
* Returns external account authorized user credentials defined by a JSON file stream.
129129
*
130+
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
131+
* external source for authentication to Google Cloud Platform, you must validate it before
132+
* providing it to any Google API or library. Providing an unvalidated credential configuration to
133+
* Google APIs can compromise the security of your systems and data. For more information, refer
134+
* to {@link <a
135+
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
136+
*
130137
* @param credentialsStream the stream with the credential definition
131138
* @return the credential defined by the credentialsStream
132139
* @throws IOException if the credential cannot be created from the stream
@@ -140,6 +147,13 @@ public static ExternalAccountAuthorizedUserCredentials fromStream(InputStream cr
140147
/**
141148
* Returns external account authorized user credentials defined by a JSON file stream.
142149
*
150+
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
151+
* external source for authentication to Google Cloud Platform, you must validate it before
152+
* providing it to any Google API or library. Providing an unvalidated credential configuration to
153+
* Google APIs can compromise the security of your systems and data. For more information, refer
154+
* to {@link <a
155+
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
156+
*
143157
* @param credentialsStream the stream with the credential definition
144158
* @param transportFactory the HTTP transport factory used to create the transport to get access
145159
* tokens

oauth2_http/java/com/google/auth/oauth2/ExternalAccountCredentials.java

+14
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,13 @@ public Map<String, List<String>> getRequestMetadata(URI uri) throws IOException
349349
*
350350
* <p>Returns {@link IdentityPoolCredentials} or {@link AwsCredentials}.
351351
*
352+
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
353+
* external source for authentication to Google Cloud Platform, you must validate it before
354+
* providing it to any Google API or library. Providing an unvalidated credential configuration to
355+
* Google APIs can compromise the security of your systems and data. For more information, refer
356+
* to {@link <a
357+
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
358+
*
352359
* @param credentialsStream the stream with the credential definition
353360
* @return the credential defined by the credentialsStream
354361
* @throws IOException if the credential cannot be created from the stream
@@ -363,6 +370,13 @@ public static ExternalAccountCredentials fromStream(InputStream credentialsStrea
363370
*
364371
* <p>Returns a {@link IdentityPoolCredentials} or {@link AwsCredentials}.
365372
*
373+
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
374+
* external source for authentication to Google Cloud Platform, you must validate it before
375+
* providing it to any Google API or library. Providing an unvalidated credential configuration to
376+
* Google APIs can compromise the security of your systems and data. For more information, refer
377+
* to {@link <a
378+
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
379+
*
366380
* @param credentialsStream the stream with the credential definition
367381
* @param transportFactory the HTTP transport factory used to create the transport to get access
368382
* tokens

oauth2_http/java/com/google/auth/oauth2/GoogleCredentials.java

+14
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ public static GoogleCredentials getApplicationDefault(HttpTransportFactory trans
158158
* <p>The stream can contain a Service Account key file in JSON format from the Google Developers
159159
* Console or a stored user credential using the format supported by the Cloud SDK.
160160
*
161+
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
162+
* external source for authentication to Google Cloud Platform, you must validate it before
163+
* providing it to any Google API or library. Providing an unvalidated credential configuration to
164+
* Google APIs can compromise the security of your systems and data. For more information, refer
165+
* to {@link <a
166+
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
167+
*
161168
* @param credentialsStream the stream with the credential definition.
162169
* @return the credential defined by the credentialsStream.
163170
* @throws IOException if the credential cannot be created from the stream.
@@ -172,6 +179,13 @@ public static GoogleCredentials fromStream(InputStream credentialsStream) throws
172179
* <p>The stream can contain a Service Account key file in JSON format from the Google Developers
173180
* Console or a stored user credential using the format supported by the Cloud SDK.
174181
*
182+
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
183+
* external source for authentication to Google Cloud Platform, you must validate it before
184+
* providing it to any Google API or library. Providing an unvalidated credential configuration to
185+
* Google APIs can compromise the security of your systems and data. For more information, refer
186+
* to {@link <a
187+
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
188+
*
175189
* @param credentialsStream the stream with the credential definition.
176190
* @param transportFactory HTTP transport factory, creates the transport used to get access
177191
* tokens.

oauth2_http/java/com/google/auth/oauth2/ServiceAccountCredentials.java

+14
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,13 @@ static ServiceAccountCredentials fromPkcs8(
446446
* Returns credentials defined by a Service Account key file in JSON format from the Google
447447
* Developers Console.
448448
*
449+
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
450+
* external source for authentication to Google Cloud Platform, you must validate it before
451+
* providing it to any Google API or library. Providing an unvalidated credential configuration to
452+
* Google APIs can compromise the security of your systems and data. For more information, refer
453+
* to {@link <a
454+
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
455+
*
449456
* @param credentialsStream the stream with the credential definition.
450457
* @return the credential defined by the credentialsStream.
451458
* @throws IOException if the credential cannot be created from the stream.
@@ -459,6 +466,13 @@ public static ServiceAccountCredentials fromStream(InputStream credentialsStream
459466
* Returns credentials defined by a Service Account key file in JSON format from the Google
460467
* Developers Console.
461468
*
469+
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
470+
* external source for authentication to Google Cloud Platform, you must validate it before
471+
* providing it to any Google API or library. Providing an unvalidated credential configuration to
472+
* Google APIs can compromise the security of your systems and data. For more information, refer
473+
* to {@link <a
474+
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
475+
*
462476
* @param credentialsStream the stream with the credential definition.
463477
* @param transportFactory HTTP transport factory, creates the transport used to get access
464478
* tokens.

0 commit comments

Comments
 (0)