]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard_v2: Don't use localized config for auth
authorRicardo Marques <rimarques@suse.com>
Tue, 30 Jan 2018 23:30:23 +0000 (23:30 +0000)
committerRicardo Dias <rdias@suse.com>
Mon, 5 Mar 2018 13:07:04 +0000 (13:07 +0000)
Signed-off-by: Ricardo Marques <rimarques@suse.com>
src/pybind/mgr/dashboard_v2/controllers/auth.py
src/pybind/mgr/dashboard_v2/tests/test_auth.py

index 5d28592a40cea268e2d53a35c17569c65cb0d57c..e239e398969f1db42dd572c6a5c68a34229f86f5 100644 (file)
@@ -28,8 +28,8 @@ class Auth(RESTController):
     @RESTController.args_from_json
     def create(self, username, password, stay_signed_in=False):
         now = time.time()
-        config_username = self.mgr.get_localized_config('username', None)
-        config_password = self.mgr.get_localized_config('password', None)
+        config_username = self.mgr.get_config('username', None)
+        config_password = self.mgr.get_config('password', None)
         hash_password = Auth.password_hash(password,
                                            config_password)
         if username == config_username and hash_password == config_password:
@@ -66,7 +66,7 @@ class Auth(RESTController):
             raise cherrypy.HTTPError(401, 'You are not authorized to access '
                                           'that resource')
         now = time.time()
-        expires = float(Auth.mgr.get_localized_config(
+        expires = float(Auth.mgr.get_config(
             'session-expire', Session.DEFAULT_EXPIRE))
         if expires > 0:
             username_ts = cherrypy.session.get(Session.TS, None)
@@ -81,6 +81,6 @@ class Auth(RESTController):
 
     @staticmethod
     def set_login_credentials(username, password):
-        Auth.mgr.set_localized_config('username', username)
+        Auth.mgr.set_config('username', username)
         hashed_passwd = Auth.password_hash(password)
-        Auth.mgr.set_localized_config('password', hashed_passwd)
+        Auth.mgr.set_config('password', hashed_passwd)
index 0e8846f09131a7763478aa7c9d0dd7e4ca3ef608..88eacc44a2fed028571460654d5a9c92fa86438b 100644 (file)
@@ -25,21 +25,19 @@ class AuthTest(ControllerTestCase):
     def setup_test(cls):
         cherrypy.tree.mount(Ping(), "/api/test",
                             config={'/': {'tools.authenticate.on': True}})
-        cls._mgr_module.set_localized_config('session-expire', '2')
-        cls._mgr_module.set_localized_config('username', 'admin')
-        cls._mgr_module.set_localized_config('password',
-                                             Auth.password_hash('admin'))
+        cls._mgr_module.set_config('session-expire', '2')
+        cls._mgr_module.set_config('username', 'admin')
+        cls._mgr_module.set_config('password', Auth.password_hash('admin'))
 
     def setUp(self):
-        self._mgr_module.set_localized_config('session-expire', '2')
-        self._mgr_module.set_localized_config('username', 'admin')
-        self._mgr_module.set_localized_config('password',
-                                              Auth.password_hash('admin'))
+        self._mgr_module.set_config('session-expire', '2')
+        self._mgr_module.set_config('username', 'admin')
+        self._mgr_module.set_config('password', Auth.password_hash('admin'))
 
     def test_a_set_login_credentials(self):
         Auth.set_login_credentials('admin2', 'admin2')
-        user = self._mgr_module.get_localized_config('username')
-        passwd = self._mgr_module.get_localized_config('password')
+        user = self._mgr_module.get_config('username')
+        passwd = self._mgr_module.get_config('password')
         self.assertEqual(user, 'admin2')
         self.assertEqual(passwd, Auth.password_hash('admin2', passwd))