From 2823013b45dfa25d0c98ee238add8f5808db3c93 Mon Sep 17 00:00:00 2001 From: Ricardo Dias Date: Fri, 20 Apr 2018 16:37:11 +0100 Subject: [PATCH] mgr/dashboard: load and cofigure authorization system Signed-off-by: Ricardo Dias --- src/pybind/mgr/dashboard/module.py | 9 +++++++++ src/pybind/mgr/dashboard/tests/helper.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index cd91d2a1a2e..cb2baa3a7eb 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -61,6 +61,9 @@ from .controllers import generate_routes, json_error_page from .controllers.auth import Auth from .tools import SessionExpireAtBrowserCloseTool, NotificationQueue, \ RequestLoggingTool, TaskManager +from .services.auth import AuthManager +from .services.access_control import ACCESS_CONTROL_COMMANDS, \ + handle_access_control_command from .services.exception import dashboard_exception_handler from .settings import options_command_list, options_schema_list, \ handle_option_command @@ -227,6 +230,7 @@ class Module(MgrModule, SSLCherryPyConfig): }, ] COMMANDS.extend(options_command_list()) + COMMANDS.extend(ACCESS_CONTROL_COMMANDS) OPTIONS = [ {'name': 'server_addr'}, @@ -268,6 +272,8 @@ class Module(MgrModule, SSLCherryPyConfig): if 'COVERAGE_ENABLED' in os.environ: _cov.start() + AuthManager.initialize() + uri = self.await_configuration() if uri is None: # We were shut down while waiting @@ -314,6 +320,9 @@ class Module(MgrModule, SSLCherryPyConfig): def handle_command(self, inbuf, cmd): res = handle_option_command(cmd) + if res[0] != -errno.ENOSYS: + return res + res = handle_access_control_command(cmd) if res[0] != -errno.ENOSYS: return res if cmd['prefix'] == 'dashboard set-login-credentials': diff --git a/src/pybind/mgr/dashboard/tests/helper.py b/src/pybind/mgr/dashboard/tests/helper.py index e98a770c621..6b578a08713 100644 --- a/src/pybind/mgr/dashboard/tests/helper.py +++ b/src/pybind/mgr/dashboard/tests/helper.py @@ -11,8 +11,8 @@ from cherrypy._cptools import HandlerWrapperTool from cherrypy.test import helper from .. import logger -from ..controllers.auth import Auth from ..controllers import json_error_page, generate_controller_routes +from ..controllers.auth import Auth from ..services.exception import dashboard_exception_handler from ..tools import SessionExpireAtBrowserCloseTool -- 2.39.5