1616
1717package acl
1818
19- import iampolicy "github.com/minio/minio/pkg/iam/policy"
19+ import (
20+ iampolicy "github.com/minio/minio/pkg/iam/policy"
21+ )
2022
2123// endpoints definition
2224var (
3537 serviceAccounts = "/service-accounts"
3638 clusters = "/clusters"
3739 clustersDetail = "/clusters/:clusterName"
40+ heal = "/heal"
3841)
3942
4043type ConfigurationActionSet struct {
@@ -195,6 +198,16 @@ var clustersActionSet = ConfigurationActionSet{
195198 actions : iampolicy .NewActionSet (),
196199}
197200
201+ // healActionSet contains the list of admin actions required for this endpoint to work
202+ var healActionSet = ConfigurationActionSet {
203+ actionTypes : iampolicy .NewActionSet (
204+ iampolicy .AllAdminActions ,
205+ ),
206+ actions : iampolicy .NewActionSet (
207+ iampolicy .HealAdminAction ,
208+ ),
209+ }
210+
198211// endpointRules contains the mapping between endpoints and ActionSets, additional rules can be added here
199212var endpointRules = map [string ]ConfigurationActionSet {
200213 configuration : configurationActionSet ,
@@ -210,10 +223,18 @@ var endpointRules = map[string]ConfigurationActionSet{
210223 buckets : bucketsActionSet ,
211224 bucketsDetail : bucketsActionSet ,
212225 serviceAccounts : serviceAccountsActionSet ,
213- clusters : clustersActionSet ,
214- clustersDetail : clustersActionSet ,
226+ heal : healActionSet ,
227+ }
228+
229+ // operatorRules contains the mapping between endpoints and ActionSets for operator only mode
230+ var operatorRules = map [string ]ConfigurationActionSet {
231+ clusters : clustersActionSet ,
232+ clustersDetail : clustersActionSet ,
215233}
216234
235+ // operatorOnly ENV variable
236+ var operatorOnly = GetOperatorOnly ()
237+
217238// GetActionsStringFromPolicy extract the admin/s3 actions from a given policy and return them in []string format
218239//
219240// ie:
@@ -263,13 +284,19 @@ func actionsStringToActionSet(actions []string) iampolicy.ActionSet {
263284// GetAuthorizedEndpoints return a list of allowed endpoint based on a provided *iampolicy.Policy
264285// ie: pages the user should have access based on his current privileges
265286func GetAuthorizedEndpoints (actions []string ) []string {
287+ rangeTake := endpointRules
288+
289+ if operatorOnly == "on" {
290+ rangeTake = operatorRules
291+ }
292+
266293 if len (actions ) == 0 {
267294 return []string {}
268295 }
269296 // Prepare new ActionSet structure that will hold all the user actions
270297 userAllowedAction := actionsStringToActionSet (actions )
271298 allowedEndpoints := []string {}
272- for endpoint , rules := range endpointRules {
299+ for endpoint , rules := range rangeTake {
273300 // check if user policy matches s3:* or admin:* typesIntersection
274301 endpointActionTypes := rules .actionTypes
275302 typesIntersection := endpointActionTypes .Intersection (userAllowedAction )
0 commit comments