mirror of
https://github.com/versity/versitygw.git
synced 2026-09-20 06:54:47 +00:00
feat: Server side region added to AdminConfig, v4 signature calculation implemented with server side region
This commit is contained in:
@@ -32,12 +32,13 @@ const (
|
||||
iso8601Format = "20060102T150405Z"
|
||||
)
|
||||
|
||||
type AdminUser struct {
|
||||
type AdminConfig struct {
|
||||
AdminAccess string
|
||||
AdminSecret string
|
||||
Region string
|
||||
}
|
||||
|
||||
func VerifyV4Signature(user AdminUser) fiber.Handler {
|
||||
func VerifyV4Signature(config AdminConfig) fiber.Handler {
|
||||
return func(ctx *fiber.Ctx) error {
|
||||
authorization := ctx.Get("Authorization")
|
||||
if authorization == "" {
|
||||
@@ -84,9 +85,9 @@ func VerifyV4Signature(user AdminUser) fiber.Handler {
|
||||
signer := v4.NewSigner()
|
||||
|
||||
signErr := signer.SignHTTP(req.Context(), aws.Credentials{
|
||||
AccessKeyID: user.AdminAccess,
|
||||
SecretAccessKey: user.AdminSecret,
|
||||
}, req, hexPayload, creds[3], creds[2], tdate)
|
||||
AccessKeyID: config.AdminAccess,
|
||||
SecretAccessKey: config.AdminSecret,
|
||||
}, req, hexPayload, creds[3], config.Region, tdate)
|
||||
if signErr != nil {
|
||||
return controllers.Responce[any](ctx, nil, s3err.GetAPIError(s3err.ErrAccessDenied))
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ type S3ApiServer struct {
|
||||
cert *tls.Certificate
|
||||
}
|
||||
|
||||
func New(app *fiber.App, be backend.Backend, port string, adminUser middlewares.AdminUser, opts ...Option) (*S3ApiServer, error) {
|
||||
func New(app *fiber.App, be backend.Backend, port string, adminUser middlewares.AdminConfig, opts ...Option) (*S3ApiServer, error) {
|
||||
server := &S3ApiServer{
|
||||
app: app,
|
||||
backend: be,
|
||||
|
||||
@@ -28,7 +28,7 @@ func TestNew(t *testing.T) {
|
||||
app *fiber.App
|
||||
be backend.Backend
|
||||
port string
|
||||
adminUser middlewares.AdminUser
|
||||
adminUser middlewares.AdminConfig
|
||||
}
|
||||
|
||||
app := fiber.New()
|
||||
@@ -48,7 +48,7 @@ func TestNew(t *testing.T) {
|
||||
app: app,
|
||||
be: be,
|
||||
port: port,
|
||||
adminUser: middlewares.AdminUser{},
|
||||
adminUser: middlewares.AdminConfig{},
|
||||
},
|
||||
wantS3ApiServer: &S3ApiServer{
|
||||
app: app,
|
||||
|
||||
Reference in New Issue
Block a user