-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The authorization header was being calculated incorrectly due to inco…
…rrect sorting on amz headers when there existed a header that started with an underscore. The http.Header implementation automatically camel cases headers. We were sorting the header keys before lower casing them when calculating the authorization header. Since underscore sorts differently when compared to upper and lower cased alpha characters, this created an incorrect sort order in the stringToSign. Fixed sorting to take place after lower casing header keys. Also fixed two stale tests that were failing due to unrelated issues. (#122)
- Loading branch information
1 parent
eb72495
commit 6f15864
Showing
4 changed files
with
31 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package networking | ||
|
||
// Used to correctly sort headers when creating the stringToSign for the authorization header. | ||
type CanonicalHeader struct{ | ||
key string // key is assumed to be lower cased | ||
values []string | ||
} | ||
type CanonicalHeaders []CanonicalHeader | ||
|
||
func (p CanonicalHeaders) Len() int { return len(p) } | ||
func (p CanonicalHeaders) Less(i, j int) bool { return p[i].key < p[j].key } | ||
func (p CanonicalHeaders) Swap(i, j int) { p[i], p[j] = p[j], p[i] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters