google: support AWS 3rd party credentials

This commit is contained in:
Ryan Kohler
2021-01-26 08:45:25 -08:00
parent af13f521f1
commit d6857d1e58
3 changed files with 651 additions and 38 deletions

View File

@@ -9,6 +9,7 @@ import (
"fmt"
"golang.org/x/oauth2"
"net/http"
"strconv"
"time"
)
@@ -67,6 +68,17 @@ type CredentialSource struct {
// parse determines the type of CredentialSource needed
func (c *Config) parse(ctx context.Context) baseCredentialSource {
if len(c.CredentialSource.EnvironmentID) > 3 && c.CredentialSource.EnvironmentID[:3] == "aws" {
if _, err := strconv.Atoi(c.CredentialSource.EnvironmentID[3:]); err == nil {
return awsCredentialSource{
EnvironmentID: c.CredentialSource.EnvironmentID,
RegionURL: c.CredentialSource.RegionURL,
RegionalCredVerificationURL: c.CredentialSource.RegionalCredVerificationURL,
CredVerificationURL: c.CredentialSource.URL,
TargetResource: c.Audience,
}
}
}
if c.CredentialSource.File != "" {
return fileCredentialSource{File: c.CredentialSource.File, Format: c.CredentialSource.Format}
} else if c.CredentialSource.URL != "" {