Changes requested by @lsirac

This commit is contained in:
Ryan Kohler
2022-04-19 12:22:53 -07:00
parent 9f3304e2ea
commit 1c93c2e4af
2 changed files with 17 additions and 35 deletions

View File

@@ -56,7 +56,7 @@ func CreateExecutableCredential(ec ExecutableConfig, config *Config, ctx context
return
}
type subjectTokenResponse struct {
type executableResponse struct {
Version *int `json:"version"`
Success *bool `json:"success"`
TokenType *string `json:"token_type"`
@@ -68,7 +68,7 @@ type subjectTokenResponse struct {
}
func parseSubjectToken(response []byte) (string, error) {
var result subjectTokenResponse
var result executableResponse
if err := json.Unmarshal(response, &result); err != nil {
return "", errors.New("oauth2/google: Unable to parse response JSON.")
}
@@ -132,10 +132,6 @@ func parseSubjectToken(response []byte) (string, error) {
}
func (cs executableCredentialSource) subjectToken() (string, error) {
if token, ok := cs.getTokenFromInMemoryCaching(); ok {
return token, nil
}
if token, ok := cs.getTokenFromOutputFile(); ok {
return token, nil
}
@@ -143,11 +139,6 @@ func (cs executableCredentialSource) subjectToken() (string, error) {
return cs.getTokenFromExecutableCommand()
}
func (cs executableCredentialSource) getTokenFromInMemoryCaching() (string, bool) {
// TODO
return "", false
}
func (cs executableCredentialSource) getTokenFromOutputFile() (string, bool) {
// TODO
return "", false
@@ -176,11 +167,7 @@ func (cs executableCredentialSource) getNewEnvironmentVariables() map[string]str
}
}
if cs.isInteractive() {
result["GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE"] = "1"
} else {
result["GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE"] = "0"
}
result["GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE"] = "0"
if cs.OutputFile != "" {
result["GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE"] = cs.OutputFile
@@ -189,11 +176,6 @@ func (cs executableCredentialSource) getNewEnvironmentVariables() map[string]str
return result
}
func (cs executableCredentialSource) isInteractive() bool {
// Currently, executableCredentialSource does not yet support interactive mode.
return false
}
func (cs executableCredentialSource) getTokenFromExecutableCommand() (string, error) {
// For security reasons, we need our consumers to set this environment variable to allow executables to be run.
if getenv("GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES") != "1" {