From dd47bdfeaa75362def0ffd352ed59a83b6dfb1a8 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 19 Jun 2020 12:37:57 -0700 Subject: [PATCH] fix: support STS for admin commands (#3264) --- cmd/client-admin.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/client-admin.go b/cmd/client-admin.go index 62e818a9..bf3eaba9 100644 --- a/cmd/client-admin.go +++ b/cmd/client-admin.go @@ -1,5 +1,5 @@ /* - * MinIO Client (C) 2017 MinIO, Inc. + * MinIO Client (C) 2017-2020 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import ( "github.com/minio/mc/pkg/httptracer" "github.com/minio/mc/pkg/probe" + "github.com/minio/minio-go/v6/pkg/credentials" "github.com/minio/minio/pkg/madmin" ) @@ -63,9 +64,15 @@ func NewAdminFactory() func(config *Config) (*madmin.AdminClient, *probe.Error) var api *madmin.AdminClient var found bool if api, found = clientCache[confSum]; !found { + // Admin API only supports signature v4. + creds := credentials.NewStaticV4(config.AccessKey, config.SecretKey, config.SessionToken) + // Not found. Instantiate a new MinIO var e error - api, e = madmin.New(hostName, config.AccessKey, config.SecretKey, useTLS) + api, e = madmin.NewWithOptions(hostName, &madmin.Options{ + Creds: creds, + Secure: useTLS, + }) if e != nil { return nil, probe.NewError(e) }