forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support application default credentials (ADC) for Google Pub/Sub (ela…
…stic#15668) Update the Google Pub/Sub input to support reading Application Default Credentials (ADC) in addition to the credentials_file and credentials_json config options. If neither config option is set then it will attempt to search for the default credentials. Generally this means reading the GOOGLE_APPLICATION_CREDENTIALS environment variable plus search a few other well known locations. The googlecloud module was updates to support all three authentication mechanisms. Co-authored-by: Michal Wasilewski <mwasilewski@gmx.com> Co-authored-by: Andrew Kroh <andrew.kroh@elastic.co> (cherry picked from commit 058de35)
- Loading branch information
1 parent
fb9fbff
commit b087e35
Showing
12 changed files
with
99 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package googlepubsub | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
const googleApplicationCredentialsVar = "GOOGLE_APPLICATION_CREDENTIALS" | ||
|
||
func TestConfigValidateGoogleAppDefaultCreds(t *testing.T) { | ||
// Return the environment variables to their original state. | ||
original, found := os.LookupEnv(googleApplicationCredentialsVar) | ||
defer func() { | ||
if found { | ||
os.Setenv(googleApplicationCredentialsVar, original) | ||
} else { | ||
os.Unsetenv(googleApplicationCredentialsVar) | ||
} | ||
}() | ||
|
||
// Validate that it finds the application default credentials and does | ||
// not trigger a config validation error because credentials were not | ||
// set in the config. | ||
os.Setenv(googleApplicationCredentialsVar, filepath.Clean("testdata/fake.json")) | ||
c := defaultConfig() | ||
assert.NoError(t, c.Validate()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"type": "service_account", | ||
"project_id": "foo", | ||
"private_key_id": "x", | ||
"private_key": "", | ||
"client_email": "foo@bar.com", | ||
"client_id": "0", | ||
"auth_uri": "https://accounts.google.com/o/oauth2/auth", | ||
"token_uri": "https://oauth2.googleapis.com/token", | ||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", | ||
"client_x509_cert_url": "https://foo.bar/path" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters