From 1491b2c31b9198e0e7206173466f63202d8ada2b Mon Sep 17 00:00:00 2001 From: stevensbkang Date: Thu, 1 Aug 2024 08:41:35 +1200 Subject: [PATCH] refactor(k8s): removal of rbac utils --- api/http/rbacutils/rbac_utils.go | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 api/http/rbacutils/rbac_utils.go diff --git a/api/http/rbacutils/rbac_utils.go b/api/http/rbacutils/rbac_utils.go deleted file mode 100644 index 38c142aea..000000000 --- a/api/http/rbacutils/rbac_utils.go +++ /dev/null @@ -1,30 +0,0 @@ -package rbacutils - -import ( - "fmt" - - portainer "github.com/portainer/portainer/api" - "github.com/portainer/portainer/api/dataservices" - "github.com/portainer/portainer/api/kubernetes/cli" -) - -// IsAdmin checks if user is a Portainer Admin based on the user's access policies -// if the user is not in the UserAccessPolicies map, then the user is an admin -// otherwise, the user defaults to a standard user in CE -// for non-admin users, allowed namespaces will be returned -func IsAdmin(user *portainer.User, endpoint *portainer.Endpoint, dataStore dataservices.DataStore, clientFactory *cli.ClientFactory) (bool, []string, error) { - if user == nil { - return false, nil, fmt.Errorf("an error occurred during the IsAdmin operation, user is nil. Unable to check if user is an admin") - } - - // use constants - if user.Role != 1 { - nonAdminNamespaces, err := cli.GetNonAdminNamespaces(int(user.ID), endpoint, clientFactory) - if err != nil { - return false, nil, fmt.Errorf("an error occurred during the IsAdmin operation, unable to retrieve non-admin namespaces. Error: %v", err) - } - return false, nonAdminNamespaces, nil - } - - return true, nil, nil -}