mirror of
https://github.com/minio/minio.git
synced 2024-12-25 22:55: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...))
|
svcAccountPolicy = svcAccountPolicy.Merge(globalIAMSys.GetCombinedPolicy(policiesNames...))
|
||||||
}
|
}
|
||||||
|
|
||||||
policyJSON, err := json.Marshal(svcAccountPolicy)
|
policyJSON, err := json.MarshalIndent(svcAccountPolicy, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
return
|
return
|
||||||
@ -1057,8 +1057,7 @@ func (a adminAPIHandlers) AccountInfoHandler(w http.ResponseWriter, r *http.Requ
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
p := globalIAMSys.GetCombinedPolicy(policies...)
|
buf, err := json.MarshalIndent(globalIAMSys.GetCombinedPolicy(policies...), "", " ")
|
||||||
buf, err := json.Marshal(p)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
return
|
return
|
||||||
@ -1115,11 +1114,12 @@ func (a adminAPIHandlers) InfoCannedPolicy(w http.ResponseWriter, r *http.Reques
|
|||||||
return
|
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)
|
writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
w.(http.Flusher).Flush()
|
w.Write(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListBucketPolicies - GET /minio/admin/v3/list-canned-policies?bucket={bucket}
|
// 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()
|
sys.store.rlock()
|
||||||
defer sys.store.runlock()
|
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 {
|
if !ok {
|
||||||
return iampolicy.Policy{}, errNoSuchPolicy
|
return iampolicy.Policy{}, errNoSuchPolicy
|
||||||
}
|
}
|
||||||
|
combinedPolicy = combinedPolicy.Merge(v)
|
||||||
return v, nil
|
}
|
||||||
|
return combinedPolicy, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListPolicies - lists all canned policies.
|
// ListPolicies - lists all canned policies.
|
||||||
|
Loading…
Reference in New Issue
Block a user