Skip to content

Commit e7d4380

Browse files
fix: indicate non-validated external credentials in generic methods (#1798)
1 parent 5511913 commit e7d4380

File tree

6 files changed

+65
-1
lines changed

6 files changed

+65
-1
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,35 @@ To run the tests you will need:
15211521
$ mvn test
15221522
```
15231523

1524+
## Versioning
1525+
1526+
This library follows [Semantic Versioning](http://semver.org/), but with some
1527+
additional qualifications:
1528+
1529+
1. Components marked with `@ObsoleteApi` are stable for usage in the current major version,
1530+
but will be marked with `@Deprecated` in a future major version.
1531+
**NOTE**: We reserve the right to mark anything as `@Deprecated` and introduce breaking
1532+
changes in a minor version to fix any ***critical bugs and
1533+
vulnerabilities***.
1534+
1535+
1. Components marked with `@InternalApi` are technically public, but are only
1536+
public for technical reasons, because of the limitations of Java's access
1537+
modifiers. For the purposes of semver, they should be considered private.
1538+
1539+
1. Components marked with `@InternalExtensionOnly` are stable for usage, but
1540+
not for extension. Thus, methods will not be removed from interfaces marked
1541+
with this annotation, but methods can be added, thus breaking any
1542+
code implementing the interface. See the javadocs for more details on other
1543+
consequences of this annotation.
1544+
1545+
1. Components marked with `@BetaApi` are considered to be "0.x" features inside
1546+
a "1.x" library. This means they can change between minor and patch releases
1547+
in incompatible ways. These features should not be used by any library "B"
1548+
that itself has consumers, unless the components of library B that use
1549+
`@BetaApi` features are also marked with `@BetaApi`. Features marked as
1550+
`@BetaApi` are on a path to eventually become "1.x" features with the marker
1551+
removed.
1552+
15241553
## License
15251554

15261555
BSD 3-Clause - See [LICENSE](LICENSE) for more information.

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,13 @@ public static ExternalAccountCredentials fromStream(
404404
/**
405405
* Returns external account credentials defined by JSON using the format generated by gCloud.
406406
*
407+
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
408+
* external source for authentication to Google Cloud Platform, you must validate it before
409+
* providing it to any Google API or library. Providing an unvalidated credential configuration to
410+
* Google APIs can compromise the security of your systems and data. For more information, refer
411+
* to {@link <a
412+
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
413+
*
407414
* @param json a map from the JSON representing the credentials
408415
* @param transportFactory HTTP transport factory, creates the transport used to get access tokens
409416
* @return the credentials defined by the JSON

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.google.api.client.json.JsonFactory;
3636
import com.google.api.client.json.JsonObjectParser;
3737
import com.google.api.client.util.Preconditions;
38+
import com.google.api.core.ObsoleteApi;
3839
import com.google.auth.Credentials;
3940
import com.google.auth.http.HttpTransportFactory;
4041
import com.google.common.annotations.VisibleForTesting;
@@ -208,6 +209,8 @@ public static GoogleCredentials getApplicationDefault(HttpTransportFactory trans
208209
* @return the credential defined by the credentialsStream.
209210
* @throws IOException if the credential cannot be created from the stream.
210211
*/
212+
@ObsoleteApi(
213+
"This method is obsolete because of a potential security risk. Use the credential specific load method instead")
211214
public static GoogleCredentials fromStream(InputStream credentialsStream) throws IOException {
212215
return fromStream(credentialsStream, OAuth2Utils.HTTP_TRANSPORT_FACTORY);
213216
}
@@ -231,6 +234,8 @@ public static GoogleCredentials fromStream(InputStream credentialsStream) throws
231234
* @return the credential defined by the credentialsStream.
232235
* @throws IOException if the credential cannot be created from the stream.
233236
*/
237+
@ObsoleteApi(
238+
"This method is obsolete because of a potential security risk. Use the credential specific load method instead")
234239
public static GoogleCredentials fromStream(
235240
InputStream credentialsStream, HttpTransportFactory transportFactory) throws IOException {
236241
Preconditions.checkNotNull(credentialsStream);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,13 @@ public byte[] sign(byte[] toSign) {
365365
* The source credentials in the JSON should be either user account credentials or service account
366366
* credentials.
367367
*
368+
* <p>Important: If you accept a credential configuration (credential JSON/File/Stream) from an
369+
* external source for authentication to Google Cloud Platform, you must validate it before
370+
* providing it to any Google API or library. Providing an unvalidated credential configuration to
371+
* Google APIs can compromise the security of your systems and data. For more information, refer
372+
* to {@link <a
373+
* href="https://cloud.google.com/docs/authentication/external/externally-sourced-credentials">documentation</a>}.
374+
*
368375
* @param json a map from the JSON representing the credentials
369376
* @param transportFactory HTTP transport factory, creates the transport used to get access tokens
370377
* @return the credentials defined by the JSON

oauth2_http/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,10 @@
325325
<artifactId>error_prone_annotations</artifactId>
326326
<scope>compile</scope>
327327
</dependency>
328+
<dependency>
329+
<groupId>com.google.api</groupId>
330+
<artifactId>api-common</artifactId>
331+
</dependency>
328332
<dependency>
329333
<groupId>junit</groupId>
330334
<artifactId>junit</artifactId>

pom.xml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@
8080
<project.appengine.version>2.0.33</project.appengine.version>
8181
<project.findbugs.version>3.0.2</project.findbugs.version>
8282
<deploy.autorelease>false</deploy.autorelease>
83-
<project.error-prone.version>2.37.0</project.error-prone.version>
83+
<project.error-prone.version>2.38.0</project.error-prone.version>
8484
<project.protobuf.version>3.25.5</project.protobuf.version>
8585
<project.cel.version>0.9.0-proto3</project.cel.version>
8686
<project.tink.version>1.15.0</project.tink.version>
8787
<project.slf4j.version>2.0.17</project.slf4j.version>
8888
<project.gson.version>2.12.1</project.gson.version>
89+
<project.api-common.version>2.53.0</project.api-common.version>
8990
</properties>
9091

9192
<dependencyManagement>
@@ -195,6 +196,17 @@
195196
</exclusion>
196197
</exclusions>
197198
</dependency>
199+
<dependency>
200+
<groupId>com.google.api</groupId>
201+
<artifactId>api-common</artifactId>
202+
<version>${project.api-common.version}</version>
203+
<exclusions>
204+
<exclusion>
205+
<groupId>com.google.guava</groupId>
206+
<artifactId>guava</artifactId>
207+
</exclusion>
208+
</exclusions>
209+
</dependency>
198210
</dependencies>
199211
</dependencyManagement>
200212

0 commit comments

Comments
 (0)