Bump AWS SDK

Fixes https://github.com/docker/distribution/issues/3097

Signed-off-by: Yong Wen Chua <lawliet89@users.noreply.github.com>
This commit is contained in:
Yong Wen Chua 2020-03-09 15:09:54 +08:00
parent 492a10376c
commit e1464fd317
No known key found for this signature in database
GPG key ID: A70BD30B21497EA9
200 changed files with 33190 additions and 7451 deletions

View file

@ -32,6 +32,19 @@ func (t AWSEpochTime) MarshalJSON() ([]byte, error) {
return []byte(fmt.Sprintf(`{"AWS:EpochTime":%d}`, t.UTC().Unix())), nil
}
// UnmarshalJSON unserializes AWS Profile epoch time.
func (t *AWSEpochTime) UnmarshalJSON(data []byte) error {
var epochTime struct {
Sec int64 `json:"AWS:EpochTime"`
}
err := json.Unmarshal(data, &epochTime)
if err != nil {
return err
}
t.Time = time.Unix(epochTime.Sec, 0).UTC()
return nil
}
// An IPAddress wraps an IPAddress source IP providing JSON serialization information
type IPAddress struct {
SourceIP string `json:"AWS:SourceIp"`
@ -169,11 +182,10 @@ func NewCannedPolicy(resource string, expires time.Time) *Policy {
// encodePolicy encodes the Policy as JSON and also base 64 encodes it.
func encodePolicy(p *Policy) (b64Policy, jsonPolicy []byte, err error) {
jsonPolicy, err = json.Marshal(p)
jsonPolicy, err = encodePolicyJSON(p)
if err != nil {
return nil, nil, fmt.Errorf("failed to encode policy, %s", err.Error())
}
// Remove leading and trailing white space, JSON encoding will note include
// whitespace within the encoding.
jsonPolicy = bytes.TrimSpace(jsonPolicy)

View file

@ -0,0 +1,14 @@
// +build !go1.7
package sign
import (
"bytes"
"encoding/json"
)
func encodePolicyJSON(p *Policy) ([]byte, error) {
src, err := json.Marshal(p)
// Convert \u0026 back to &
return bytes.Replace(src, []byte("\\u0026"), []byte("&"), -1), err
}

View file

@ -0,0 +1,16 @@
// +build go1.7
package sign
import (
"bytes"
"encoding/json"
)
func encodePolicyJSON(p *Policy) ([]byte, error) {
buffer := &bytes.Buffer{}
encoder := json.NewEncoder(buffer)
encoder.SetEscapeHTML(false)
err := encoder.Encode(p)
return buffer.Bytes(), err
}

View file

@ -179,7 +179,7 @@ func cookieURLScheme(u string) (string, error) {
//
// // Or get Signed cookies for a resource that will expire in 1 hour
// // and set path and domain of cookies
// cookies, err := s.Sign(policy, func(o *sign.CookieOptions) {
// cookies, err := s.SignWithPolicy(policy, func(o *sign.CookieOptions) {
// o.Path = "/"
// o.Domain = ".example.com"
// })