Skip to content
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

DEVPROD-774: allow temporary session tokens for signing and GetHeadObject #108

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1353,11 +1353,12 @@ const PresignExpireTime = 24 * time.Hour

// PreSignRequestParams holds all the parameters needed to sign a URL or fetch S3 object metadata.
type PreSignRequestParams struct {
Bucket string `json:"bucket"`
FileKey string `json:"fileKey"`
AwsKey string `json:"awsKey"`
AwsSecret string `json:"awsSecret"`
Region string `json:"region"`
Bucket string
FileKey string
AwsKey string
AwsSecret string
AwsSessionToken string
Region string
}

// PreSign returns a presigned URL that expires in 24 hours.
Expand All @@ -1367,6 +1368,7 @@ func PreSign(r PreSignRequestParams) (string, error) {
Credentials: credentials.NewStaticCredentialsFromCreds(credentials.Value{
AccessKeyID: r.AwsKey,
SecretAccessKey: r.AwsSecret,
SessionToken: r.AwsSessionToken,
}),
})
if err != nil {
Expand All @@ -1390,6 +1392,7 @@ func GetHeadObject(r PreSignRequestParams) (*s3.HeadObjectOutput, error) {
Credentials: credentials.NewStaticCredentialsFromCreds(credentials.Value{
AccessKeyID: r.AwsKey,
SecretAccessKey: r.AwsSecret,
SessionToken: r.AwsSessionToken,
}),
})
if err != nil {
Expand Down