-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Improve sts header parsing #3013
Improve sts header parsing #3013
Conversation
builtin/credential/aws/path_login.go
Outdated
@@ -1407,7 +1406,38 @@ func parseGetCallerIdentityResponse(response string) (GetCallerIdentityResponse, | |||
return result, err | |||
} | |||
|
|||
func submitCallerIdentityRequest(method, endpoint string, parsedUrl *url.URL, body string, headers http.Header) (*GetCallerIdentityResult, error) { | |||
func parseIamRequestHeaders(headersB64 string) (*http.Header, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http.Header
is a typedef for map[string][]string
and as such it's a reference type -- return it directly, not as a pointer.
builtin/credential/aws/path_login.go
Outdated
} | ||
} | ||
default: | ||
return nil, fmt.Errorf("Header %q value %q has type %s, not string or []interface", k, typedValue, reflect.TypeOf(v)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Header/header -- same above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for the header being a pointer. Unfortunately fixing this will require backing out half the changes you made in the first place...sorry!
This refactors the parsing of iam_request_headers parameter into a separate method to make it easy to add unit tests around the parsing, in preparation for relaxing the header requirements (issue 2810).
This allows headers to be of both map[string][]string (which is http.Header -- the existing format) and map[string]string to be more interoperable with other languages and SDKs.
f7c1389
to
03fdfb2
Compare
Done.
No, thank you, I learned something new about go so it's great! :) |
Looks good -- thanks! |
I'm not sure if this is the best way to do so in go, so please let me know if there's a better way of accomplishing this!
Fixes #2810