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

fix(internal): don't use self-signed JWT with impersonation #788

Merged
merged 6 commits into from Jan 29, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions internal/creds.go
Expand Up @@ -64,14 +64,18 @@ const (

// credentialsFromJSON returns a google.Credentials based on the input.
//
// - If the JSON is a service account and no scopes provided, returns self-signed JWT auth flow
// - Otherwise, returns OAuth 2.0 flow.
// - If the JSON is a service account, no user are scopes provided, an audience
// is provided, and credentials will not be impersonated executes a
codyoss marked this conversation as resolved.
Show resolved Hide resolved
// signed JWT auth flow.
// - Otherwise, executes a stanard OAuth 2.0 flow.
func credentialsFromJSON(ctx context.Context, data []byte, ds *DialSettings) (*google.Credentials, error) {
cred, err := google.CredentialsFromJSON(ctx, data, ds.GetScopes()...)
if err != nil {
return nil, err
}
if len(data) > 0 && len(ds.Scopes) == 0 && (ds.DefaultAudience != "" || len(ds.Audiences) > 0) {
if len(data) > 0 && len(ds.Scopes) == 0 &&
(ds.DefaultAudience != "" || len(ds.Audiences) > 0) &&
ds.ImpersonationConfig == nil {
codyoss marked this conversation as resolved.
Show resolved Hide resolved
var f struct {
Type string `json:"type"`
// The rest JSON fields are omitted because they are not used.
Expand Down