2021-04-18 15:41:13 -04:00
|
|
|
// Copyright (c) 2015-2021 MinIO, Inc.
|
|
|
|
//
|
|
|
|
// This file is part of MinIO Object Storage stack
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2019-11-19 05:03:18 -05:00
|
|
|
|
|
|
|
package iampolicy
|
|
|
|
|
|
|
|
import (
|
2020-01-27 17:12:34 -05:00
|
|
|
"github.com/minio/minio/pkg/bucket/policy/condition"
|
2019-11-19 05:03:18 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// AdminAction - admin policy action.
|
|
|
|
type AdminAction string
|
|
|
|
|
|
|
|
const (
|
|
|
|
// HealAdminAction - allows heal command
|
|
|
|
HealAdminAction = "admin:Heal"
|
|
|
|
|
|
|
|
// Service Actions
|
|
|
|
|
2020-01-26 21:47:52 -05:00
|
|
|
// StorageInfoAdminAction - allow listing server info
|
|
|
|
StorageInfoAdminAction = "admin:StorageInfo"
|
2021-04-22 21:55:30 -04:00
|
|
|
// PrometheusAdminAction - prometheus info action
|
|
|
|
PrometheusAdminAction = "admin:Prometheus"
|
2020-01-26 21:47:52 -05:00
|
|
|
// DataUsageInfoAdminAction - allow listing data usage info
|
|
|
|
DataUsageInfoAdminAction = "admin:DataUsageInfo"
|
2021-01-25 13:01:27 -05:00
|
|
|
// ForceUnlockAdminAction - allow force unlocking locks
|
|
|
|
ForceUnlockAdminAction = "admin:ForceUnlock"
|
2020-01-26 21:47:52 -05:00
|
|
|
// TopLocksAdminAction - allow listing top locks
|
|
|
|
TopLocksAdminAction = "admin:TopLocksInfo"
|
|
|
|
// ProfilingAdminAction - allow profiling
|
|
|
|
ProfilingAdminAction = "admin:Profiling"
|
|
|
|
// TraceAdminAction - allow listing server trace
|
|
|
|
TraceAdminAction = "admin:ServerTrace"
|
|
|
|
// ConsoleLogAdminAction - allow listing console logs on terminal
|
|
|
|
ConsoleLogAdminAction = "admin:ConsoleLog"
|
2020-07-08 21:50:43 -04:00
|
|
|
// KMSCreateKeyAdminAction - allow creating a new KMS master key
|
|
|
|
KMSCreateKeyAdminAction = "admin:KMSCreateKey"
|
2020-01-26 21:47:52 -05:00
|
|
|
// KMSKeyStatusAdminAction - allow getting KMS key status
|
|
|
|
KMSKeyStatusAdminAction = "admin:KMSKeyStatus"
|
|
|
|
// ServerInfoAdminAction - allow listing server info
|
|
|
|
ServerInfoAdminAction = "admin:ServerInfo"
|
2020-11-20 15:52:53 -05:00
|
|
|
// HealthInfoAdminAction - allow obtaining cluster health information
|
|
|
|
HealthInfoAdminAction = "admin:OBDInfo"
|
2020-10-09 23:36:00 -04:00
|
|
|
// BandwidthMonitorAction - allow monitoring bandwidth usage
|
|
|
|
BandwidthMonitorAction = "admin:BandwidthMonitor"
|
2019-11-19 05:03:18 -05:00
|
|
|
|
|
|
|
// ServerUpdateAdminAction - allow MinIO binary update
|
|
|
|
ServerUpdateAdminAction = "admin:ServerUpdate"
|
2020-05-11 13:34:08 -04:00
|
|
|
// ServiceRestartAdminAction - allow restart of MinIO service.
|
|
|
|
ServiceRestartAdminAction = "admin:ServiceRestart"
|
|
|
|
// ServiceStopAdminAction - allow stopping MinIO service.
|
|
|
|
ServiceStopAdminAction = "admin:ServiceStop"
|
2019-11-19 05:03:18 -05:00
|
|
|
|
|
|
|
// ConfigUpdateAdminAction - allow MinIO config management
|
|
|
|
ConfigUpdateAdminAction = "admin:ConfigUpdate"
|
|
|
|
|
|
|
|
// CreateUserAdminAction - allow creating MinIO user
|
|
|
|
CreateUserAdminAction = "admin:CreateUser"
|
|
|
|
// DeleteUserAdminAction - allow deleting MinIO user
|
|
|
|
DeleteUserAdminAction = "admin:DeleteUser"
|
|
|
|
// ListUsersAdminAction - allow list users permission
|
|
|
|
ListUsersAdminAction = "admin:ListUsers"
|
|
|
|
// EnableUserAdminAction - allow enable user permission
|
|
|
|
EnableUserAdminAction = "admin:EnableUser"
|
|
|
|
// DisableUserAdminAction - allow disable user permission
|
|
|
|
DisableUserAdminAction = "admin:DisableUser"
|
|
|
|
// GetUserAdminAction - allows GET permission on user info
|
|
|
|
GetUserAdminAction = "admin:GetUser"
|
|
|
|
|
2021-04-15 01:51:14 -04:00
|
|
|
// Service account Actions
|
|
|
|
|
|
|
|
// CreateServiceAccountAdminAction - allow create a service account for a user
|
|
|
|
CreateServiceAccountAdminAction = "admin:CreateServiceAccount"
|
|
|
|
// UpdateServiceAccountAdminAction - allow updating a service account
|
|
|
|
UpdateServiceAccountAdminAction = "admin:UpdateServiceAccount"
|
|
|
|
// RemoveServiceAccountAdminAction - allow removing a service account
|
|
|
|
RemoveServiceAccountAdminAction = "admin:RemoveServiceAccount"
|
|
|
|
// ListServiceAccountsAdminAction - allow listing service accounts
|
|
|
|
ListServiceAccountsAdminAction = "admin:ListServiceAccounts"
|
|
|
|
|
2019-11-19 05:03:18 -05:00
|
|
|
// Group Actions
|
|
|
|
|
|
|
|
// AddUserToGroupAdminAction - allow adding user to group permission
|
|
|
|
AddUserToGroupAdminAction = "admin:AddUserToGroup"
|
|
|
|
// RemoveUserFromGroupAdminAction - allow removing user to group permission
|
|
|
|
RemoveUserFromGroupAdminAction = "admin:RemoveUserFromGroup"
|
|
|
|
// GetGroupAdminAction - allow getting group info
|
|
|
|
GetGroupAdminAction = "admin:GetGroup"
|
|
|
|
// ListGroupsAdminAction - allow list groups permission
|
|
|
|
ListGroupsAdminAction = "admin:ListGroups"
|
|
|
|
// EnableGroupAdminAction - allow enable group permission
|
|
|
|
EnableGroupAdminAction = "admin:EnableGroup"
|
|
|
|
// DisableGroupAdminAction - allow disable group permission
|
|
|
|
DisableGroupAdminAction = "admin:DisableGroup"
|
|
|
|
|
|
|
|
// Policy Actions
|
|
|
|
|
|
|
|
// CreatePolicyAdminAction - allow create policy permission
|
|
|
|
CreatePolicyAdminAction = "admin:CreatePolicy"
|
|
|
|
// DeletePolicyAdminAction - allow delete policy permission
|
|
|
|
DeletePolicyAdminAction = "admin:DeletePolicy"
|
|
|
|
// GetPolicyAdminAction - allow get policy permission
|
|
|
|
GetPolicyAdminAction = "admin:GetPolicy"
|
|
|
|
// AttachPolicyAdminAction - allows attaching a policy to a user/group
|
|
|
|
AttachPolicyAdminAction = "admin:AttachUserOrGroupPolicy"
|
|
|
|
// ListUserPoliciesAdminAction - allows listing user policies
|
|
|
|
ListUserPoliciesAdminAction = "admin:ListUserPolicies"
|
2020-04-30 18:55:54 -04:00
|
|
|
|
|
|
|
// Bucket quota Actions
|
|
|
|
|
|
|
|
// SetBucketQuotaAdminAction - allow setting bucket quota
|
|
|
|
SetBucketQuotaAdminAction = "admin:SetBucketQuota"
|
|
|
|
// GetBucketQuotaAdminAction - allow getting bucket quota
|
|
|
|
GetBucketQuotaAdminAction = "admin:GetBucketQuota"
|
|
|
|
|
2020-07-28 14:50:47 -04:00
|
|
|
// Bucket Target admin Actions
|
2020-07-21 20:49:56 -04:00
|
|
|
|
2020-07-28 14:50:47 -04:00
|
|
|
// SetBucketTargetAction - allow setting bucket target
|
|
|
|
SetBucketTargetAction = "admin:SetBucketTarget"
|
|
|
|
// GetBucketTargetAction - allow getting bucket targets
|
|
|
|
GetBucketTargetAction = "admin:GetBucketTarget"
|
2020-07-21 20:49:56 -04:00
|
|
|
|
2021-04-19 13:30:42 -04:00
|
|
|
// Remote Tier admin Actions
|
|
|
|
|
|
|
|
// SetTierAction - allow adding/editing a remote tier
|
|
|
|
SetTierAction = "admin:SetTier"
|
|
|
|
// ListTierAction - allow listing remote tiers
|
|
|
|
ListTierAction = "admin:ListTier"
|
|
|
|
|
2019-11-19 05:03:18 -05:00
|
|
|
// AllAdminActions - provides all admin permissions
|
|
|
|
AllAdminActions = "admin:*"
|
|
|
|
)
|
|
|
|
|
|
|
|
// List of all supported admin actions.
|
|
|
|
var supportedAdminActions = map[AdminAction]struct{}{
|
2021-04-15 01:51:14 -04:00
|
|
|
HealAdminAction: {},
|
|
|
|
StorageInfoAdminAction: {},
|
|
|
|
DataUsageInfoAdminAction: {},
|
|
|
|
TopLocksAdminAction: {},
|
|
|
|
ProfilingAdminAction: {},
|
2021-04-22 21:55:30 -04:00
|
|
|
PrometheusAdminAction: {},
|
2021-04-15 01:51:14 -04:00
|
|
|
TraceAdminAction: {},
|
|
|
|
ConsoleLogAdminAction: {},
|
|
|
|
KMSKeyStatusAdminAction: {},
|
|
|
|
ServerInfoAdminAction: {},
|
|
|
|
HealthInfoAdminAction: {},
|
|
|
|
BandwidthMonitorAction: {},
|
|
|
|
ServerUpdateAdminAction: {},
|
|
|
|
ServiceRestartAdminAction: {},
|
|
|
|
ServiceStopAdminAction: {},
|
|
|
|
ConfigUpdateAdminAction: {},
|
|
|
|
CreateUserAdminAction: {},
|
|
|
|
DeleteUserAdminAction: {},
|
|
|
|
ListUsersAdminAction: {},
|
|
|
|
EnableUserAdminAction: {},
|
|
|
|
DisableUserAdminAction: {},
|
|
|
|
GetUserAdminAction: {},
|
|
|
|
AddUserToGroupAdminAction: {},
|
|
|
|
RemoveUserFromGroupAdminAction: {},
|
|
|
|
GetGroupAdminAction: {},
|
|
|
|
ListGroupsAdminAction: {},
|
|
|
|
EnableGroupAdminAction: {},
|
|
|
|
DisableGroupAdminAction: {},
|
|
|
|
CreateServiceAccountAdminAction: {},
|
|
|
|
UpdateServiceAccountAdminAction: {},
|
|
|
|
RemoveServiceAccountAdminAction: {},
|
|
|
|
ListServiceAccountsAdminAction: {},
|
|
|
|
CreatePolicyAdminAction: {},
|
|
|
|
DeletePolicyAdminAction: {},
|
|
|
|
GetPolicyAdminAction: {},
|
|
|
|
AttachPolicyAdminAction: {},
|
|
|
|
ListUserPoliciesAdminAction: {},
|
|
|
|
SetBucketQuotaAdminAction: {},
|
|
|
|
GetBucketQuotaAdminAction: {},
|
|
|
|
SetBucketTargetAction: {},
|
|
|
|
GetBucketTargetAction: {},
|
2021-04-19 13:30:42 -04:00
|
|
|
SetTierAction: {},
|
|
|
|
ListTierAction: {},
|
2021-04-15 01:51:14 -04:00
|
|
|
AllAdminActions: {},
|
2019-11-19 05:03:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// IsValid - checks if action is valid or not.
|
|
|
|
func (action AdminAction) IsValid() bool {
|
|
|
|
_, ok := supportedAdminActions[action]
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// adminActionConditionKeyMap - holds mapping of supported condition key for an action.
|
|
|
|
var adminActionConditionKeyMap = map[Action]condition.KeySet{
|
2021-04-15 01:51:14 -04:00
|
|
|
AllAdminActions: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
HealAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
StorageInfoAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
ServerInfoAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
DataUsageInfoAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
HealthInfoAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
BandwidthMonitorAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
TopLocksAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
ProfilingAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
TraceAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
ConsoleLogAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
KMSKeyStatusAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
ServerUpdateAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
ServiceRestartAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
ServiceStopAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
ConfigUpdateAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
CreateUserAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
DeleteUserAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
ListUsersAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
EnableUserAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
DisableUserAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
GetUserAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
AddUserToGroupAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
RemoveUserFromGroupAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
ListGroupsAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
EnableGroupAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
DisableGroupAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
CreateServiceAccountAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
UpdateServiceAccountAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
RemoveServiceAccountAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
ListServiceAccountsAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
|
|
|
|
CreatePolicyAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
DeletePolicyAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
GetPolicyAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
AttachPolicyAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
ListUserPoliciesAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
SetBucketQuotaAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
GetBucketQuotaAdminAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
SetBucketTargetAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
GetBucketTargetAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
2021-04-19 13:30:42 -04:00
|
|
|
SetTierAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
|
|
|
ListTierAction: condition.NewKeySet(condition.AllSupportedAdminKeys...),
|
2019-11-19 05:03:18 -05:00
|
|
|
}
|