mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
always indent and reply policy JSON (#12399)
This commit is contained in:
parent
81d5688d56
commit
3350dbc50d
@ -784,7 +784,7 @@ func (a adminAPIHandlers) InfoServiceAccount(w http.ResponseWriter, r *http.Requ
|
||||
svcAccountPolicy = svcAccountPolicy.Merge(globalIAMSys.GetCombinedPolicy(policiesNames...))
|
||||
}
|
||||
|
||||
policyJSON, err := json.Marshal(svcAccountPolicy)
|
||||
policyJSON, err := json.MarshalIndent(svcAccountPolicy, "", " ")
|
||||
if err != nil {
|
||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||
return
|
||||
@ -1057,8 +1057,7 @@ func (a adminAPIHandlers) AccountInfoHandler(w http.ResponseWriter, r *http.Requ
|
||||
return
|
||||
}
|
||||
|
||||
p := globalIAMSys.GetCombinedPolicy(policies...)
|
||||
buf, err := json.Marshal(p)
|
||||
buf, err := json.MarshalIndent(globalIAMSys.GetCombinedPolicy(policies...), "", " ")
|
||||
if err != nil {
|
||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||
return
|
||||
@ -1115,11 +1114,12 @@ func (a adminAPIHandlers) InfoCannedPolicy(w http.ResponseWriter, r *http.Reques
|
||||
return
|
||||
}
|
||||
|
||||
if err = json.NewEncoder(w).Encode(policy); err != nil {
|
||||
buf, err := json.MarshalIndent(policy, "", " ")
|
||||
if err != nil {
|
||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||
return
|
||||
}
|
||||
w.(http.Flusher).Flush()
|
||||
w.Write(buf)
|
||||
}
|
||||
|
||||
// ListBucketPolicies - GET /minio/admin/v3/list-canned-policies?bucket={bucket}
|
||||
|
12
cmd/iam.go
12
cmd/iam.go
@ -738,12 +738,18 @@ func (sys *IAMSys) InfoPolicy(policyName string) (iampolicy.Policy, error) {
|
||||
sys.store.rlock()
|
||||
defer sys.store.runlock()
|
||||
|
||||
v, ok := sys.iamPolicyDocsMap[policyName]
|
||||
var combinedPolicy iampolicy.Policy
|
||||
for _, policy := range strings.Split(policyName, ",") {
|
||||
if policy == "" {
|
||||
continue
|
||||
}
|
||||
v, ok := sys.iamPolicyDocsMap[policy]
|
||||
if !ok {
|
||||
return iampolicy.Policy{}, errNoSuchPolicy
|
||||
}
|
||||
|
||||
return v, nil
|
||||
combinedPolicy = combinedPolicy.Merge(v)
|
||||
}
|
||||
return combinedPolicy, nil
|
||||
}
|
||||
|
||||
// ListPolicies - lists all canned policies.
|
||||
|
Loading…
Reference in New Issue
Block a user