mirror of
https://github.com/ceph/ceph
synced 2025-05-04 16:48:27 +00:00
mgr/dashboard: Login failure should return HTTP 400
Signed-off-by: Ricardo Marques <rimarques@suse.com>
This commit is contained in:
parent
7b3a7306b6
commit
091e01ca71
@ -47,8 +47,12 @@ class AuthTest(DashboardTestCase):
|
|||||||
|
|
||||||
def test_login_invalid(self):
|
def test_login_invalid(self):
|
||||||
self._post("/api/auth", {'username': 'admin', 'password': 'inval'})
|
self._post("/api/auth", {'username': 'admin', 'password': 'inval'})
|
||||||
self.assertStatus(403)
|
self.assertStatus(400)
|
||||||
self.assertJsonBody({"detail": "Invalid credentials"})
|
self.assertJsonBody({
|
||||||
|
"component": "auth",
|
||||||
|
"code": "invalid_credentials",
|
||||||
|
"detail": "Invalid credentials"
|
||||||
|
})
|
||||||
|
|
||||||
def test_logout(self):
|
def test_logout(self):
|
||||||
self._post("/api/auth", {'username': 'admin', 'password': 'admin'})
|
self._post("/api/auth", {'username': 'admin', 'password': 'admin'})
|
||||||
|
@ -8,6 +8,7 @@ import cherrypy
|
|||||||
|
|
||||||
from . import ApiController, RESTController
|
from . import ApiController, RESTController
|
||||||
from .. import logger, mgr
|
from .. import logger, mgr
|
||||||
|
from ..exceptions import DashboardException
|
||||||
from ..tools import Session
|
from ..tools import Session
|
||||||
|
|
||||||
|
|
||||||
@ -40,13 +41,14 @@ class Auth(RESTController):
|
|||||||
logger.debug('Login successful')
|
logger.debug('Login successful')
|
||||||
return {'username': username}
|
return {'username': username}
|
||||||
|
|
||||||
cherrypy.response.status = 403
|
|
||||||
if config_username is None:
|
if config_username is None:
|
||||||
logger.warning('No Credentials configured. Need to call `ceph dashboard '
|
logger.warning('No Credentials configured. Need to call `ceph dashboard '
|
||||||
'set-login-credentials <username> <password>` first.')
|
'set-login-credentials <username> <password>` first.')
|
||||||
else:
|
else:
|
||||||
logger.debug('Login failed')
|
logger.debug('Login failed')
|
||||||
return {'detail': 'Invalid credentials'}
|
raise DashboardException(msg='Invalid credentials',
|
||||||
|
code='invalid_credentials',
|
||||||
|
component='auth')
|
||||||
|
|
||||||
def bulk_delete(self):
|
def bulk_delete(self):
|
||||||
logger.debug('Logout successful')
|
logger.debug('Logout successful')
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
export enum Components {
|
export enum Components {
|
||||||
|
auth = 'Login',
|
||||||
cephfs = 'CephFS',
|
cephfs = 'CephFS',
|
||||||
rbd = 'RBD',
|
rbd = 'RBD',
|
||||||
pool = 'Pool',
|
pool = 'Pool',
|
||||||
|
Loading…
Reference in New Issue
Block a user