forked from TrueCloudLab/distribution
Support session token
Signed-off-by: Troels Thomsen <troels@thomsen.io>
This commit is contained in:
parent
e85ef3c019
commit
7f510ae9c9
3 changed files with 10 additions and 0 deletions
|
@ -98,6 +98,7 @@ type DriverParameters struct {
|
||||||
StorageClass string
|
StorageClass string
|
||||||
UserAgent string
|
UserAgent string
|
||||||
ObjectACL string
|
ObjectACL string
|
||||||
|
SessionToken string
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -331,6 +332,8 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
|
||||||
objectACL = objectACLString
|
objectACL = objectACLString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sessionToken := ""
|
||||||
|
|
||||||
params := DriverParameters{
|
params := DriverParameters{
|
||||||
fmt.Sprint(accessKey),
|
fmt.Sprint(accessKey),
|
||||||
fmt.Sprint(secretKey),
|
fmt.Sprint(secretKey),
|
||||||
|
@ -349,6 +352,7 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
|
||||||
storageClass,
|
storageClass,
|
||||||
fmt.Sprint(userAgent),
|
fmt.Sprint(userAgent),
|
||||||
objectACL,
|
objectACL,
|
||||||
|
fmt.Sprint(sessionToken),
|
||||||
}
|
}
|
||||||
|
|
||||||
return New(params)
|
return New(params)
|
||||||
|
@ -398,6 +402,7 @@ func New(params DriverParameters) (*Driver, error) {
|
||||||
Value: credentials.Value{
|
Value: credentials.Value{
|
||||||
AccessKeyID: params.AccessKey,
|
AccessKeyID: params.AccessKey,
|
||||||
SecretAccessKey: params.SecretKey,
|
SecretAccessKey: params.SecretKey,
|
||||||
|
SessionToken: params.SessionToken,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&credentials.EnvProvider{},
|
&credentials.EnvProvider{},
|
||||||
|
|
|
@ -36,6 +36,7 @@ func init() {
|
||||||
objectACL := os.Getenv("S3_OBJECT_ACL")
|
objectACL := os.Getenv("S3_OBJECT_ACL")
|
||||||
root, err := ioutil.TempDir("", "driver-")
|
root, err := ioutil.TempDir("", "driver-")
|
||||||
regionEndpoint := os.Getenv("REGION_ENDPOINT")
|
regionEndpoint := os.Getenv("REGION_ENDPOINT")
|
||||||
|
sessionToken := os.Getenv("AWS_SESSION_TOKEN")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -84,6 +85,7 @@ func init() {
|
||||||
storageClass,
|
storageClass,
|
||||||
driverName + "-test",
|
driverName + "-test",
|
||||||
objectACL,
|
objectACL,
|
||||||
|
sessionToken,
|
||||||
}
|
}
|
||||||
|
|
||||||
return New(parameters)
|
return New(parameters)
|
||||||
|
|
|
@ -137,6 +137,9 @@ func (v2 *signer) Sign() error {
|
||||||
host, canonicalPath := parsedURL.Host, parsedURL.Path
|
host, canonicalPath := parsedURL.Host, parsedURL.Path
|
||||||
v2.Request.Header["Host"] = []string{host}
|
v2.Request.Header["Host"] = []string{host}
|
||||||
v2.Request.Header["date"] = []string{v2.Time.In(time.UTC).Format(time.RFC1123)}
|
v2.Request.Header["date"] = []string{v2.Time.In(time.UTC).Format(time.RFC1123)}
|
||||||
|
if credValue.SessionToken != "" {
|
||||||
|
v2.Request.Header["x-amz-security-token"] = []string{credValue.SessionToken}
|
||||||
|
}
|
||||||
|
|
||||||
smap = make(map[string]string)
|
smap = make(map[string]string)
|
||||||
for k, v := range headers {
|
for k, v := range headers {
|
||||||
|
|
Loading…
Reference in a new issue