noobaa / noobaa-core

High-performance S3 application gateway to any backend - file / s3-compatible / multi-clouds / caching / replication ...
https://www.noobaa.io
Apache License 2.0
268 stars 78 forks source link

Support S3 CORS API #6080

Open wpfnihao opened 4 years ago

wpfnihao commented 4 years ago

Is your feature request related to a problem? Please describe. When using aws s3 sdk to set cors rules, error occurred. code:

func setCors(bucketName string) error {
 region := "cn-northwest-1"
 if tools.Config.S3Region != "" {
  region = tools.Config.S3Region
 }
 sess := session.Must(session.NewSessionWithOptions(session.Options{
  SharedConfigState: session.SharedConfigEnable,
  Config: aws.Config{
   Region:   aws.String(region),
   Endpoint: aws.String(Key.EndPoint), //Bucket所在Endpoint
   HTTPClient: func() *http.Client {
    return &http.Client{
     Transport: func() *http.Transport {
      return &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
     }(),
     Timeout: 3 * time.Second,
    }
   }(),
   //S3ForcePathStyle: aws.Bool(true),
  },
 }))
 svc := s3.New(sess)
 rule := s3.CORSRule{
  AllowedHeaders: aws.StringSlice([]string{"*"}),
  AllowedOrigins: aws.StringSlice([]string{"*"}),
  MaxAgeSeconds:  aws.Int64(3000),
  // Add HTTP methods CORS request that were specified in the CLI.
  AllowedMethods: aws.StringSlice([]string{"PUT", "POST", "GET"}),
 }
 params := s3.PutBucketCorsInput{
  Bucket: aws.String(bucketName),
  CORSConfiguration: &s3.CORSConfiguration{
   CORSRules: []*s3.CORSRule{&rule},
  },
 }
 _, err := svc.PutBucketCors(&params)
 if err != nil {
  log.Println("setCors, invoke s3 PutBucketCors error:", err)
  return err
 }
 log.Printf("setCors, Updated bucket %q CORS finished\n", bucketName)
 return nil
}

error message from noobaa:

A header you provided implies functionality that is not implemented. status code: 501, request id: kc1muixr-as3c6z-12kx, host id: kc1muixr-as3c6z-12kx

Describe the solution you'd like Support S3 CORS API, just like S3 BucketPolicy API support in v5.3 'Bomberman'.

Describe alternatives you've considered Still thinking about it. If Noobaa developers know about any workarounds, please let me know.

Additional context NA.

github-actions[bot] commented 1 month ago

This issue had no activity for too long - it will now be labeled stale. Update it to prevent it from getting closed.

github-actions[bot] commented 4 days ago

This issue is stale and had no activity for too long - it will now be closed.