]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Login failure should return HTTP 400 22403/head
authorRicardo Marques <rimarques@suse.com>
Mon, 4 Jun 2018 20:26:44 +0000 (21:26 +0100)
committerRicardo Marques <rimarques@suse.com>
Wed, 6 Jun 2018 10:45:09 +0000 (11:45 +0100)
Signed-off-by: Ricardo Marques <rimarques@suse.com>
qa/tasks/mgr/dashboard/test_auth.py
src/pybind/mgr/dashboard/controllers/auth.py
src/pybind/mgr/dashboard/frontend/src/app/shared/enum/components.enum.ts

index 29350e2dc92c2e09c96ba2cebc27bc773d370832..6f2cc7946977c815a4269cfef718cd410fe36bb0 100644 (file)
@@ -47,8 +47,12 @@ class AuthTest(DashboardTestCase):
 
     def test_login_invalid(self):
         self._post("/api/auth", {'username': 'admin', 'password': 'inval'})
-        self.assertStatus(403)
-        self.assertJsonBody({"detail": "Invalid credentials"})
+        self.assertStatus(400)
+        self.assertJsonBody({
+            "component": "auth",
+            "code": "invalid_credentials",
+            "detail": "Invalid credentials"
+        })
 
     def test_logout(self):
         self._post("/api/auth", {'username': 'admin', 'password': 'admin'})
index 1cbad91cb86b483e5f1146c06237c9d279f89930..be6c3298fe648f7fe499c4719664c849d4757757 100644 (file)
@@ -8,6 +8,7 @@ import cherrypy
 
 from . import ApiController, RESTController
 from .. import logger, mgr
+from ..exceptions import DashboardException
 from ..tools import Session
 
 
@@ -40,13 +41,14 @@ class Auth(RESTController):
             logger.debug('Login successful')
             return {'username': username}
 
-        cherrypy.response.status = 403
         if config_username is None:
             logger.warning('No Credentials configured. Need to call `ceph dashboard '
                            'set-login-credentials <username> <password>` first.')
         else:
             logger.debug('Login failed')
-        return {'detail': 'Invalid credentials'}
+        raise DashboardException(msg='Invalid credentials',
+                                 code='invalid_credentials',
+                                 component='auth')
 
     def bulk_delete(self):
         logger.debug('Logout successful')
index f5fc998f341f1cceec5ea760bfee3397e8d78e45..2c6dd9b1766deeda79fdc47cd6f627e9b52a7200 100644 (file)
@@ -1,4 +1,5 @@
 export enum Components {
+  auth = 'Login',
   cephfs = 'CephFS',
   rbd = 'RBD',
   pool = 'Pool',