]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/security.py
update ceph source to reef 18.2.0
[ceph.git] / ceph / src / pybind / mgr / dashboard / security.py
1 # -*- coding: utf-8 -*-
2
3 import inspect
4
5
6 class Scope(object):
7 """
8 List of Dashboard Security Scopes.
9 If you need another security scope, please add it here.
10 """
11
12 HOSTS = "hosts"
13 CONFIG_OPT = "config-opt"
14 POOL = "pool"
15 OSD = "osd"
16 MONITOR = "monitor"
17 RBD_IMAGE = "rbd-image"
18 ISCSI = "iscsi"
19 RBD_MIRRORING = "rbd-mirroring"
20 RGW = "rgw"
21 CEPHFS = "cephfs"
22 MANAGER = "manager"
23 LOG = "log"
24 GRAFANA = "grafana"
25 PROMETHEUS = "prometheus"
26 USER = "user"
27 DASHBOARD_SETTINGS = "dashboard-settings"
28 NFS_GANESHA = "nfs-ganesha"
29
30 @classmethod
31 def all_scopes(cls):
32 return [val for scope, val in
33 inspect.getmembers(cls,
34 lambda memb: not inspect.isroutine(memb))
35 if not scope.startswith('_')]
36
37 @classmethod
38 def valid_scope(cls, scope_name):
39 return scope_name in cls.all_scopes()
40
41
42 class Permission(object):
43 """
44 Scope permissions types
45 """
46 READ = "read"
47 CREATE = "create"
48 UPDATE = "update"
49 DELETE = "delete"
50
51 @classmethod
52 def all_permissions(cls):
53 return [val for perm, val in
54 inspect.getmembers(cls,
55 lambda memb: not inspect.isroutine(memb))
56 if not perm.startswith('_')]
57
58 @classmethod
59 def valid_permission(cls, perm_name):
60 return perm_name in cls.all_permissions()