eat: Closes #317, Changed s3 proxy behavior to run in single user mode with CLI provided credentials

This commit is contained in:
jonaustin09
2023-12-04 10:06:59 -05:00
parent 4a81f7a7a5
commit c5007a68aa
3 changed files with 25 additions and 10 deletions
+1 -8
View File
@@ -17,7 +17,6 @@ package s3proxy
import (
"context"
"crypto/tls"
"fmt"
"net/http"
"github.com/aws/aws-sdk-go-v2/aws"
@@ -26,16 +25,10 @@ import (
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/smithy-go/middleware"
"github.com/versity/versitygw/auth"
)
func (s *S3be) getClientFromCtx(ctx context.Context) (*s3.Client, error) {
acct, ok := ctx.Value("account").(auth.Account)
if !ok {
return nil, fmt.Errorf("invalid account in context")
}
cfg, err := s.getConfig(ctx, acct.Access, acct.Secret)
cfg, err := s.getConfig(ctx, s.access, s.secret)
if err != nil {
return nil, err
}
+5 -1
View File
@@ -35,6 +35,8 @@ import (
type S3be struct {
backend.BackendUnsupported
access string
secret string
endpoint string
awsRegion string
disableChecksum bool
@@ -42,8 +44,10 @@ type S3be struct {
debug bool
}
func New(endpoint, region string, disableChecksum, sslSkipVerify, debug bool) *S3be {
func New(access, secret, endpoint, region string, disableChecksum, sslSkipVerify, debug bool) *S3be {
return &S3be{
access: access,
secret: secret,
endpoint: endpoint,
awsRegion: region,
disableChecksum: disableChecksum,
+19 -1
View File
@@ -20,6 +20,8 @@ import (
)
var (
s3proxyAccess string
s3proxySecret string
s3proxyEndpoint string
s3proxyRegion string
s3proxyDisableChecksum bool
@@ -35,6 +37,22 @@ func s3Command() *cli.Command {
to an s3 storage backend service.`,
Action: runS3,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "access",
Usage: "s3 proxy server access key id",
Value: "",
Required: true,
Destination: &s3proxyAccess,
Aliases: []string{"a"},
},
&cli.StringFlag{
Name: "secret",
Usage: "s3 proxy server secret access key",
Value: "",
Required: true,
Destination: &s3proxySecret,
Aliases: []string{"s"},
},
&cli.StringFlag{
Name: "endpoint",
Usage: "s3 service endpoint, default AWS if not specified",
@@ -70,7 +88,7 @@ to an s3 storage backend service.`,
}
func runS3(ctx *cli.Context) error {
be := s3proxy.New(s3proxyEndpoint, s3proxyRegion,
be := s3proxy.New(s3proxyAccess, s3proxySecret, s3proxyEndpoint, s3proxyRegion,
s3proxyDisableChecksum, s3proxySslSkipVerify, s3proxyDebug)
return runGateway(ctx.Context, be)
}