mirror of
https://github.com/minio/minio.git
synced 2025-01-26 22:23:15 -05:00
fix: accountInfo API to cater for federated setups (#11484)
when MinIO is deployed in a federated setup, use etcd based listing of buckets to provide appropriate filtering of buckets per user.
This commit is contained in:
parent
3afa499885
commit
84d400487f
@ -23,8 +23,10 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/minio/minio/cmd/config/dns"
|
||||||
"github.com/minio/minio/cmd/logger"
|
"github.com/minio/minio/cmd/logger"
|
||||||
"github.com/minio/minio/pkg/auth"
|
"github.com/minio/minio/pkg/auth"
|
||||||
iampolicy "github.com/minio/minio/pkg/iam/policy"
|
iampolicy "github.com/minio/minio/pkg/iam/policy"
|
||||||
@ -688,12 +690,6 @@ func (a adminAPIHandlers) AccountInfoHandler(w http.ResponseWriter, r *http.Requ
|
|||||||
return rd, wr
|
return rd, wr
|
||||||
}
|
}
|
||||||
|
|
||||||
buckets, err := objectAPI.ListBuckets(ctx)
|
|
||||||
if err != nil {
|
|
||||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the latest calculated data usage
|
// Load the latest calculated data usage
|
||||||
dataUsageInfo, err := loadDataUsageFromBackend(ctx, objectAPI)
|
dataUsageInfo, err := loadDataUsageFromBackend(ctx, objectAPI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -701,6 +697,33 @@ func (a adminAPIHandlers) AccountInfoHandler(w http.ResponseWriter, r *http.Requ
|
|||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If etcd, dns federation configured list buckets from etcd.
|
||||||
|
var buckets []BucketInfo
|
||||||
|
if globalDNSConfig != nil && globalBucketFederation {
|
||||||
|
dnsBuckets, err := globalDNSConfig.List()
|
||||||
|
if err != nil && !IsErrIgnored(err,
|
||||||
|
dns.ErrNoEntriesFound,
|
||||||
|
dns.ErrDomainMissing) {
|
||||||
|
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL, guessIsBrowserReq(r))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, dnsRecords := range dnsBuckets {
|
||||||
|
buckets = append(buckets, BucketInfo{
|
||||||
|
Name: dnsRecords[0].Key,
|
||||||
|
Created: dnsRecords[0].CreationDate,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
sort.Slice(buckets, func(i, j int) bool {
|
||||||
|
return buckets[i].Name < buckets[j].Name
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
buckets, err = objectAPI.ListBuckets(ctx)
|
||||||
|
if err != nil {
|
||||||
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
accountName := cred.AccessKey
|
accountName := cred.AccessKey
|
||||||
if cred.ParentUser != "" {
|
if cred.ParentUser != "" {
|
||||||
accountName = cred.ParentUser
|
accountName = cred.ParentUser
|
||||||
|
Loading…
x
Reference in New Issue
Block a user