@@ -330,12 +330,14 @@ func (s consoleSTSAssumeRole) IsExpired() bool {
330330}
331331
332332func NewConsoleCredentials (accessKey , secretKey , location string ) (* credentials.Credentials , error ) {
333+ minioURL := getMinIOServer ()
334+
333335 // Future authentication methods can be added under this switch statement
334336 switch {
335337 // LDAP authentication for Console
336338 case ldap .GetLDAPEnabled ():
337339 {
338- creds , err := auth .GetCredentialsFromLDAP (GetConsoleHTTPClient (), getMinIOServer () , accessKey , secretKey )
340+ creds , err := auth .GetCredentialsFromLDAP (GetConsoleHTTPClient (minioURL ), minioURL , accessKey , secretKey )
339341 if err != nil {
340342 return nil , err
341343 }
@@ -354,8 +356,8 @@ func NewConsoleCredentials(accessKey, secretKey, location string) (*credentials.
354356 DurationSeconds : int (xjwt .GetConsoleSTSDuration ().Seconds ()),
355357 }
356358 stsAssumeRole := & credentials.STSAssumeRole {
357- Client : GetConsoleHTTPClient (),
358- STSEndpoint : getMinIOServer () ,
359+ Client : GetConsoleHTTPClient (minioURL ),
360+ STSEndpoint : minioURL ,
359361 Options : opts ,
360362 }
361363 consoleSTSWrapper := consoleSTSAssumeRole {stsAssumeRole : stsAssumeRole }
@@ -374,10 +376,12 @@ func getConsoleCredentialsFromSession(claims *models.Principal) *credentials.Cre
374376// from the provided session token
375377func newMinioClient (claims * models.Principal ) (* minio.Client , error ) {
376378 creds := getConsoleCredentialsFromSession (claims )
377- minioClient , err := minio .New (getMinIOEndpoint (), & minio.Options {
379+ endpoint := getMinIOEndpoint ()
380+ secure := getMinIOEndpointIsSecure ()
381+ minioClient , err := minio .New (endpoint , & minio.Options {
378382 Creds : creds ,
379- Secure : getMinIOEndpointIsSecure () ,
380- Transport : GetConsoleHTTPClient ().Transport ,
383+ Secure : secure ,
384+ Transport : GetConsoleHTTPClient (getMinIOServer () ).Transport ,
381385 })
382386 if err != nil {
383387 return nil , err
@@ -414,7 +418,7 @@ func newS3BucketClient(claims *models.Principal, bucketName string, prefix strin
414418 if err != nil {
415419 return nil , fmt .Errorf ("the provided endpoint is invalid" )
416420 }
417- s3Config := newS3Config (objectURL , claims .STSAccessKeyID , claims .STSSecretAccessKey , claims .STSSessionToken , false )
421+ s3Config := newS3Config (objectURL , claims .STSAccessKeyID , claims .STSSecretAccessKey , claims .STSSessionToken )
418422 client , pErr := mc .S3New (s3Config )
419423 if pErr != nil {
420424 return nil , pErr .Cause
@@ -438,21 +442,24 @@ func pathJoinFinalSlash(elem ...string) string {
438442
439443// newS3Config simply creates a new Config struct using the passed
440444// parameters.
441- func newS3Config (endpoint , accessKey , secretKey , sessionToken string , insecure bool ) * mc.Config {
445+ func newS3Config (endpoint , accessKey , secretKey , sessionToken string ) * mc.Config {
442446 // We have a valid alias and hostConfig. We populate the/
443447 // consoleCredentials from the match found in the config file.
444448 s3Config := new (mc.Config )
445449
446450 s3Config .AppName = globalAppName
447451 s3Config .AppVersion = pkg .Version
448452 s3Config .Debug = false
449- s3Config .Insecure = insecure
450453
451454 s3Config .HostURL = endpoint
452455 s3Config .AccessKey = accessKey
453456 s3Config .SecretKey = secretKey
454457 s3Config .SessionToken = sessionToken
455458 s3Config .Signature = "S3v4"
459+
460+ insecure := isLocalIPEndpoint (endpoint )
461+
462+ s3Config .Insecure = insecure
456463 s3Config .Transport = PrepareSTSClientTransport (insecure )
457464
458465 return s3Config
0 commit comments