mirror of
https://github.com/golang/oauth2.git
synced 2025-07-21 00:00:09 +08:00
google: add warning about externally-provided credentials
Change-Id: Ic2ce6e9c3ed735f4fc6d78a22cf0d5e95fca91a1 Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/643158 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Sai Sunder Srinivasan <saisunder@google.com> Run-TryBot: Cody Oss <codyoss@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cody Oss <codyoss@google.com>
This commit is contained in:
parent
49a531d12a
commit
b9c813be7d
@ -251,6 +251,12 @@ func FindDefaultCredentials(ctx context.Context, scopes ...string) (*Credentials
|
|||||||
// a Google Developers service account key file, a gcloud user credentials file (a.k.a. refresh
|
// a Google Developers service account key file, a gcloud user credentials file (a.k.a. refresh
|
||||||
// token JSON), or the JSON configuration file for workload identity federation in non-Google cloud
|
// token JSON), or the JSON configuration file for workload identity federation in non-Google cloud
|
||||||
// platforms (see https://cloud.google.com/iam/docs/how-to#using-workload-identity-federation).
|
// platforms (see https://cloud.google.com/iam/docs/how-to#using-workload-identity-federation).
|
||||||
|
//
|
||||||
|
// Important: If you accept a credential configuration (credential JSON/File/Stream) from an
|
||||||
|
// external source for authentication to Google Cloud Platform, you must validate it before
|
||||||
|
// providing it to any Google API or library. Providing an unvalidated credential configuration to
|
||||||
|
// Google APIs can compromise the security of your systems and data. For more information, refer to
|
||||||
|
// [Validate credential configurations from external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
|
||||||
func CredentialsFromJSONWithParams(ctx context.Context, jsonData []byte, params CredentialsParams) (*Credentials, error) {
|
func CredentialsFromJSONWithParams(ctx context.Context, jsonData []byte, params CredentialsParams) (*Credentials, error) {
|
||||||
// Make defensive copy of the slices in params.
|
// Make defensive copy of the slices in params.
|
||||||
params = params.deepCopy()
|
params = params.deepCopy()
|
||||||
@ -294,6 +300,12 @@ func CredentialsFromJSONWithParams(ctx context.Context, jsonData []byte, params
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CredentialsFromJSON invokes CredentialsFromJSONWithParams with the specified scopes.
|
// CredentialsFromJSON invokes CredentialsFromJSONWithParams with the specified scopes.
|
||||||
|
//
|
||||||
|
// Important: If you accept a credential configuration (credential JSON/File/Stream) from an
|
||||||
|
// external source for authentication to Google Cloud Platform, you must validate it before
|
||||||
|
// providing it to any Google API or library. Providing an unvalidated credential configuration to
|
||||||
|
// Google APIs can compromise the security of your systems and data. For more information, refer to
|
||||||
|
// [Validate credential configurations from external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
|
||||||
func CredentialsFromJSON(ctx context.Context, jsonData []byte, scopes ...string) (*Credentials, error) {
|
func CredentialsFromJSON(ctx context.Context, jsonData []byte, scopes ...string) (*Credentials, error) {
|
||||||
var params CredentialsParams
|
var params CredentialsParams
|
||||||
params.Scopes = scopes
|
params.Scopes = scopes
|
||||||
|
@ -278,20 +278,52 @@ type Format struct {
|
|||||||
type CredentialSource struct {
|
type CredentialSource struct {
|
||||||
// File is the location for file sourced credentials.
|
// File is the location for file sourced credentials.
|
||||||
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
|
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
|
||||||
|
//
|
||||||
|
// Important: If you accept a credential configuration (credential
|
||||||
|
// JSON/File/Stream) from an external source for authentication to Google
|
||||||
|
// Cloud Platform, you must validate it before providing it to any Google
|
||||||
|
// API or library. Providing an unvalidated credential configuration to
|
||||||
|
// Google APIs can compromise the security of your systems and data. For
|
||||||
|
// more information, refer to [Validate credential configurations from
|
||||||
|
// external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
|
||||||
File string `json:"file"`
|
File string `json:"file"`
|
||||||
|
|
||||||
// Url is the URL to call for URL sourced credentials.
|
// Url is the URL to call for URL sourced credentials.
|
||||||
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
|
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
|
||||||
|
//
|
||||||
|
// Important: If you accept a credential configuration (credential
|
||||||
|
// JSON/File/Stream) from an external source for authentication to Google
|
||||||
|
// Cloud Platform, you must validate it before providing it to any Google
|
||||||
|
// API or library. Providing an unvalidated credential configuration to
|
||||||
|
// Google APIs can compromise the security of your systems and data. For
|
||||||
|
// more information, refer to [Validate credential configurations from
|
||||||
|
// external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
// Headers are the headers to attach to the request for URL sourced credentials.
|
// Headers are the headers to attach to the request for URL sourced credentials.
|
||||||
Headers map[string]string `json:"headers"`
|
Headers map[string]string `json:"headers"`
|
||||||
|
|
||||||
// Executable is the configuration object for executable sourced credentials.
|
// Executable is the configuration object for executable sourced credentials.
|
||||||
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
|
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
|
||||||
|
//
|
||||||
|
// Important: If you accept a credential configuration (credential
|
||||||
|
// JSON/File/Stream) from an external source for authentication to Google
|
||||||
|
// Cloud Platform, you must validate it before providing it to any Google
|
||||||
|
// API or library. Providing an unvalidated credential configuration to
|
||||||
|
// Google APIs can compromise the security of your systems and data. For
|
||||||
|
// more information, refer to [Validate credential configurations from
|
||||||
|
// external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
|
||||||
Executable *ExecutableConfig `json:"executable"`
|
Executable *ExecutableConfig `json:"executable"`
|
||||||
|
|
||||||
// EnvironmentID is the EnvironmentID used for AWS sourced credentials. This should start with "AWS".
|
// EnvironmentID is the EnvironmentID used for AWS sourced credentials. This should start with "AWS".
|
||||||
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
|
// One field amongst File, URL, Executable, or EnvironmentID should be provided, depending on the kind of credential in question.
|
||||||
|
//
|
||||||
|
// Important: If you accept a credential configuration (credential
|
||||||
|
// JSON/File/Stream) from an external source for authentication to Google
|
||||||
|
// Cloud Platform, you must validate it before providing it to any Google
|
||||||
|
// API or library. Providing an unvalidated credential configuration to
|
||||||
|
// Google APIs can compromise the security of your systems and data. For
|
||||||
|
// more information, refer to [Validate credential configurations from
|
||||||
|
// external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).
|
||||||
EnvironmentID string `json:"environment_id"`
|
EnvironmentID string `json:"environment_id"`
|
||||||
// RegionURL is the metadata URL to retrieve the region from for EC2 AWS credentials.
|
// RegionURL is the metadata URL to retrieve the region from for EC2 AWS credentials.
|
||||||
RegionURL string `json:"region_url"`
|
RegionURL string `json:"region_url"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user