Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google App Default Credentials Unusable #1155

Closed

Conversation

ryanhos
Copy link

@ryanhos ryanhos commented Dec 8, 2022

Closes #1151, which broke using app default credentials (and relying on workload identity on GCP hosts), by assuming that GOOGLE_CREDENTIALS would always contain a valid value.

@enchorb
Copy link

enchorb commented Jan 31, 2023

@ajvb Can you merge this

Comment on lines +241 to 247
defaultCredentials, wasSet := os.LookupEnv(SopsGoogleCredentialsEnv)
if !wasSet {
return nil, nil
} else if _, err := os.Stat(defaultCredentials); err == nil {
return os.ReadFile(defaultCredentials)
}
return []byte(defaultCredentials), nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
defaultCredentials, wasSet := os.LookupEnv(SopsGoogleCredentialsEnv)
if !wasSet {
return nil, nil
} else if _, err := os.Stat(defaultCredentials); err == nil {
return os.ReadFile(defaultCredentials)
}
return []byte(defaultCredentials), nil
if defaultCredentials, ok := os.LookupEnv(SopsGoogleCredentialsEnv); ok {
if _, err := os.Stat(defaultCredentials); err == nil {
return os.ReadFile(defaultCredentials)
}
return []byte(defaultCredentials), nil
}
return nil, nil

Seems more Go idiomatic.

@hiddeco
Copy link
Member

hiddeco commented Jul 3, 2023

Thank you for your contribution! 🙇

In addition to my review comment, it would be great if you could rebase this and sign-off your commit.

@hiddeco hiddeco added this to the v3.8.0 milestone Jul 3, 2023
@hiddeco hiddeco removed this from the v3.8.0 milestone Jul 11, 2023
@hiddeco hiddeco closed this Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implicit and explicit Google Application Default Credentials cannot be used
3 participants