From cb92f20375ffcb6393322acb37bce101105df88b Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Tue, 4 Jul 2023 18:41:27 -0400 Subject: [PATCH] Ajouter validation d'accessKeyId et secretAccessKey vides --- media/media.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/media/media.go b/media/media.go index d204b8d..2d044f0 100644 --- a/media/media.go +++ b/media/media.go @@ -1,6 +1,8 @@ package media import ( + "errors" + "git.agecem.com/agecem/agecem-org/config" "github.com/minio/minio-go/v7" "github.com/minio/minio-go/v7/pkg/credentials" @@ -8,6 +10,14 @@ import ( ) func NewMediaClient(endpoint, accessKeyId, secretAccessKey string, useSSL bool) (*MediaClient, error) { + if accessKeyId == "" { + return nil, errors.New("accessKeyId was found empty, but cannot be") + } + + if secretAccessKey == "" { + return nil, errors.New("secretAccessKey was found empty, but cannot be") + } + var mediaClient MediaClient minioClient, err := minio.New(endpoint, &minio.Options{ Creds: credentials.NewStaticV4(accessKeyId, secretAccessKey, ""),