Closed lucix-aws closed 1 month ago
Tested:
package main import ( "context" "fmt" "io" "net/http" "net/url" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/s3" ) func main() { cfg, err := config.LoadDefaultConfig(context.Background()) if err != nil { panic(err) } svc := s3.NewFromConfig(cfg) presigner := s3.NewPresignClient(svc) u, err := presigner.PresignGetObject(context.Background(), &s3.GetObjectInput{ Bucket: aws.String("<...>"), Key: aws.String("<...>"), ExpectedBucketOwner: aws.String("<... an account id number that isn't expected>"), }) if err != nil { panic(err) } println(u.URL) fmt.Printf("%#v\n", u.SignedHeader) uu, _ := url.Parse(u.URL) resp, err := http.DefaultClient.Do(&http.Request{ URL: uu, Header: u.SignedHeader, }) if err != nil { panic(err) } fmt.Println(resp.Status) p, _ := io.ReadAll(resp.Body) fmt.Println(string(p)) }
with fix the presigned GET response printed is the expected 403.
Tested:
with fix the presigned GET response printed is the expected 403.