mirror of
https://github.com/restic/restic.git
synced 2025-08-13 22:57:44 +00:00
gs: support authentication with access token
In the Google Cloud Storage backend, support specifying access tokens directly, as an alternative to a credentials file. This is useful when restic is used non-interactively by some other program that is already authenticated and eliminates the need to store long lived credentials. The access token is specified in the GOOGLE_ACCESS_TOKEN environment variable and takes precedence over GOOGLE_APPLICATION_CREDENTIALS.
This commit is contained in:
@@ -87,7 +87,6 @@ func TestBackendGS(t *testing.T) {
|
||||
}()
|
||||
|
||||
vars := []string{
|
||||
"GOOGLE_APPLICATION_CREDENTIALS",
|
||||
"RESTIC_TEST_GS_PROJECT_ID",
|
||||
"RESTIC_TEST_GS_REPOSITORY",
|
||||
}
|
||||
@@ -98,6 +97,10 @@ func TestBackendGS(t *testing.T) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if os.Getenv("GOOGLE_APPLICATION_CREDENTIALS")+os.Getenv("GOOGLE_ACCESS_TOKEN") == "" {
|
||||
t.Skipf("environment variable GOOGLE_APPLICATION_CREDENTIALS not set, nor GOOGLE_ACCESS_TOKEN")
|
||||
return
|
||||
}
|
||||
|
||||
t.Logf("run tests")
|
||||
newGSTestSuite(t).RunTests(t)
|
||||
@@ -105,7 +108,6 @@ func TestBackendGS(t *testing.T) {
|
||||
|
||||
func BenchmarkBackendGS(t *testing.B) {
|
||||
vars := []string{
|
||||
"GOOGLE_APPLICATION_CREDENTIALS",
|
||||
"RESTIC_TEST_GS_PROJECT_ID",
|
||||
"RESTIC_TEST_GS_REPOSITORY",
|
||||
}
|
||||
@@ -116,6 +118,10 @@ func BenchmarkBackendGS(t *testing.B) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if os.Getenv("GOOGLE_APPLICATION_CREDENTIALS")+os.Getenv("GOOGLE_ACCESS_TOKEN") == "" {
|
||||
t.Skipf("environment variable GOOGLE_APPLICATION_CREDENTIALS not set, nor GOOGLE_ACCESS_TOKEN")
|
||||
return
|
||||
}
|
||||
|
||||
t.Logf("run tests")
|
||||
newGSTestSuite(t).RunBenchmarks(t)
|
||||
|
Reference in New Issue
Block a user