From bde0f444dbab7c35bd5e856cb28f56e6b25605da Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 15 Apr 2020 12:16:40 -0700 Subject: [PATCH] fix support OBDAdminAction is valid action (#9354) --- cmd/admin-handlers-users.go | 11 ++++++++++- pkg/iam/policy/admin-action.go | 2 ++ pkg/iam/policy/constants.go | 7 ++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cmd/admin-handlers-users.go b/cmd/admin-handlers-users.go index bb913e116..a7454c842 100644 --- a/cmd/admin-handlers-users.go +++ b/cmd/admin-handlers-users.go @@ -565,7 +565,16 @@ func (a adminAPIHandlers) ListCannedPolicies(w http.ResponseWriter, r *http.Requ return } - if err = json.NewEncoder(w).Encode(policies); err != nil { + var newPolicies = make(map[string]iampolicy.Policy) + for name, p := range policies { + _, err = json.Marshal(p) + if err != nil { + logger.LogIf(ctx, err) + continue + } + newPolicies[name] = p + } + if err = json.NewEncoder(w).Encode(newPolicies); err != nil { writeErrorResponseJSON(ctx, w, toAdminAPIErr(ctx, err), r.URL) return } diff --git a/pkg/iam/policy/admin-action.go b/pkg/iam/policy/admin-action.go index b79a987de..33c292985 100644 --- a/pkg/iam/policy/admin-action.go +++ b/pkg/iam/policy/admin-action.go @@ -115,6 +115,7 @@ var supportedAdminActions = map[AdminAction]struct{}{ TopLocksAdminAction: {}, ProfilingAdminAction: {}, TraceAdminAction: {}, + OBDInfoAdminAction: {}, ConsoleLogAdminAction: {}, KMSKeyStatusAdminAction: {}, ServerUpdateAdminAction: {}, @@ -159,6 +160,7 @@ var adminActionConditionKeyMap = map[Action]condition.KeySet{ StorageInfoAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...), ServerInfoAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...), DataUsageInfoAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...), + OBDInfoAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...), TopLocksAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...), ProfilingAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...), TraceAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...), diff --git a/pkg/iam/policy/constants.go b/pkg/iam/policy/constants.go index bf7876b8e..846b6622b 100644 --- a/pkg/iam/policy/constants.go +++ b/pkg/iam/policy/constants.go @@ -72,9 +72,10 @@ var AdminDiagnostics = Policy{ { SID: policy.ID(""), Effect: policy.Allow, - Actions: NewActionSet(ProfilingAdminAction, TraceAdminAction, - ConsoleLogAdminAction, ServerInfoAdminAction, - TopLocksAdminAction, OBDInfoAdminAction), + Actions: NewActionSet(ProfilingAdminAction, + TraceAdminAction, ConsoleLogAdminAction, + ServerInfoAdminAction, TopLocksAdminAction, + OBDInfoAdminAction), Resources: NewResourceSet(NewResource("*", "")), }, },