Skip to content

Commit b9c813b

Browse files
quartzmocodyoss
authored andcommitted
google: add warning about externally-provided credentials
Change-Id: Ic2ce6e9c3ed735f4fc6d78a22cf0d5e95fca91a1 Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/643158 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Sai Sunder Srinivasan <[email protected]> Run-TryBot: Cody Oss <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cody Oss <[email protected]>
1 parent 49a531d commit b9c813b

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

google/default.go

+12
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ func FindDefaultCredentials(ctx context.Context, scopes ...string) (*Credentials
251251
// a Google Developers service account key file, a gcloud user credentials file (a.k.a. refresh
252252
// token JSON), or the JSON configuration file for workload identity federation in non-Google cloud
253253
// platforms (see https://cloud.google.com/iam/docs/how-to#using-workload-identity-federation).
254+
//
255+
// Important: If you accept a credential configuration (credential JSON/File/Stream) from an
256+
// external source for authentication to Google Cloud Platform, you must validate it before
257+
// providing it to any Google API or library. Providing an unvalidated credential configuration to
258+
// Google APIs can compromise the security of your systems and data. For more information, refer to
259+
// [Validate credential configurations from external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
254260
func CredentialsFromJSONWithParams(ctx context.Context, jsonData []byte, params CredentialsParams) (*Credentials, error) {
255261
// Make defensive copy of the slices in params.
256262
params = params.deepCopy()
@@ -294,6 +300,12 @@ func CredentialsFromJSONWithParams(ctx context.Context, jsonData []byte, params
294300
}
295301

296302
// CredentialsFromJSON invokes CredentialsFromJSONWithParams with the specified scopes.
303+
//
304+
// Important: If you accept a credential configuration (credential JSON/File/Stream) from an
305+
// external source for authentication to Google Cloud Platform, you must validate it before
306+
// providing it to any Google API or library. Providing an unvalidated credential configuration to
307+
// Google APIs can compromise the security of your systems and data. For more information, refer to
308+
// [Validate credential configurations from external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
297309
func CredentialsFromJSON(ctx context.Context, jsonData []byte, scopes ...string) (*Credentials, error) {
298310
var params CredentialsParams
299311
params.Scopes = scopes

google/externalaccount/basecredentials.go

+32
Original file line numberDiff line numberDiff line change
@@ -278,20 +278,52 @@ type Format struct {
278278
type CredentialSource struct {
279279
// File is the location for file sourced credentials.
280280
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
281+
//
282+
// Important: If you accept a credential configuration (credential
283+
// JSON/File/Stream) from an external source for authentication to Google
284+
// Cloud Platform, you must validate it before providing it to any Google
285+
// API or library. Providing an unvalidated credential configuration to
286+
// Google APIs can compromise the security of your systems and data. For
287+
// more information, refer to [Validate credential configurations from
288+
// external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
281289
File string `json:"file"`
282290

283291
// Url is the URL to call for URL sourced credentials.
284292
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
293+
//
294+
// Important: If you accept a credential configuration (credential
295+
// JSON/File/Stream) from an external source for authentication to Google
296+
// Cloud Platform, you must validate it before providing it to any Google
297+
// API or library. Providing an unvalidated credential configuration to
298+
// Google APIs can compromise the security of your systems and data. For
299+
// more information, refer to [Validate credential configurations from
300+
// external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
285301
URL string `json:"url"`
286302
// Headers are the headers to attach to the request for URL sourced credentials.
287303
Headers map[string]string `json:"headers"`
288304

289305
// Executable is the configuration object for executable sourced credentials.
290306
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
307+
//
308+
// Important: If you accept a credential configuration (credential
309+
// JSON/File/Stream) from an external source for authentication to Google
310+
// Cloud Platform, you must validate it before providing it to any Google
311+
// API or library. Providing an unvalidated credential configuration to
312+
// Google APIs can compromise the security of your systems and data. For
313+
// more information, refer to [Validate credential configurations from
314+
// external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
291315
Executable *ExecutableConfig `json:"executable"`
292316

293317
// EnvironmentID is the EnvironmentID used for AWS sourced credentials. This should start with "AWS".
294318
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
319+
//
320+
// Important: If you accept a credential configuration (credential
321+
// JSON/File/Stream) from an external source for authentication to Google
322+
// Cloud Platform, you must validate it before providing it to any Google
323+
// API or library. Providing an unvalidated credential configuration to
324+
// Google APIs can compromise the security of your systems and data. For
325+
// more information, refer to [Validate credential configurations from
326+
// external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
295327
EnvironmentID string `json:"environment_id"`
296328
// RegionURL is the metadata URL to retrieve the region from for EC2 AWS credentials.
297329
RegionURL string `json:"region_url"`

0 commit comments

Comments
 (0)