From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/pybind/mgr/dashboard/security.py | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/pybind/mgr/dashboard/security.py (limited to 'src/pybind/mgr/dashboard/security.py') diff --git a/src/pybind/mgr/dashboard/security.py b/src/pybind/mgr/dashboard/security.py new file mode 100644 index 000000000..4c6e5c564 --- /dev/null +++ b/src/pybind/mgr/dashboard/security.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- + +import inspect + + +class Scope(object): + """ + List of Dashboard Security Scopes. + If you need another security scope, please add it here. + """ + + HOSTS = "hosts" + CONFIG_OPT = "config-opt" + POOL = "pool" + OSD = "osd" + MONITOR = "monitor" + RBD_IMAGE = "rbd-image" + ISCSI = "iscsi" + RBD_MIRRORING = "rbd-mirroring" + RGW = "rgw" + CEPHFS = "cephfs" + MANAGER = "manager" + LOG = "log" + GRAFANA = "grafana" + PROMETHEUS = "prometheus" + USER = "user" + DASHBOARD_SETTINGS = "dashboard-settings" + NFS_GANESHA = "nfs-ganesha" + + @classmethod + def all_scopes(cls): + return [val for scope, val in + inspect.getmembers(cls, + lambda memb: not inspect.isroutine(memb)) + if not scope.startswith('_')] + + @classmethod + def valid_scope(cls, scope_name): + return scope_name in cls.all_scopes() + + +class Permission(object): + """ + Scope permissions types + """ + READ = "read" + CREATE = "create" + UPDATE = "update" + DELETE = "delete" + + @classmethod + def all_permissions(cls): + return [val for perm, val in + inspect.getmembers(cls, + lambda memb: not inspect.isroutine(memb)) + if not perm.startswith('_')] + + @classmethod + def valid_permission(cls, perm_name): + return perm_name in cls.all_permissions() -- cgit v1.2.3