Skip to content
Snippets Groups Projects
Commit 3cf94a3d authored by sveseli's avatar sveseli
Browse files

renamed method to check credentials

parent fe7656d3
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,7 @@ class DmSessionController(DmController):
#auth = LoginController()
# Add before_handler for authorization
cherrypy.tools.auth = cherrypy.Tool('before_handler', LoginController.checkAuthorization)
cherrypy.tools.auth = cherrypy.Tool('before_handler', LoginController.authCheck)
def __init__(self):
DmController.__init__(self)
......
......@@ -12,7 +12,7 @@ from dm.common.exceptions.dmHttpError import DmHttpError
from dm.common.exceptions.authorizationError import AuthorizationError
from dm.common.utility.loggingManager import LoggingManager
from dm.common.service.dmController import DmController
from dm.common.service.impl.authorizationManager import AuthorizationManager
from dm.common.service.auth.authorizationPrincipalManager import AuthorizationPrincipalManager
class LoginController(DmController):
""" Controller to provide login and logout actions. """
......@@ -91,8 +91,8 @@ class LoginController(DmController):
logger.debug('Checking credential for User: %s' % (username))
#logger.debug('Checking credential for User: %s, Password: %s' % (username, password))
logger.debug('Session id: %s' % cherrypy.serving.session.id)
principal = AuthorizationManager.getInstance().getAuthorizationPrincipal(username, password)
logger.debug('Principal: %s' % (principal))
principal = AuthorizationPrincipalManager.getInstance().getAuthenticatedAuthorizationPrincipal(username, password)
#logger.debug('Principal: %s' % (principal))
if principal:
cherrypy.session[LoginController.SESSION_ROLE_KEY] = principal.getRole()
logger.debug('Successful login from user: %s (role: %s)' % (username, principal.getRole()))
......@@ -107,13 +107,13 @@ class LoginController(DmController):
return principal
@classmethod
def checkAuthorization(cls, *args, **kwargs):
def authCheck(cls, *args, **kwargs):
"""
A tool that looks in config for 'auth.require'. If found and it
is not None, a login is required and the entry is evaluated as a list of
conditions that the user must fulfill.
"""
logger = LoggingManager.getInstance().getLogger('LoginController:checkAuthorization')
logger = LoggingManager.getInstance().getLogger('LoginController:authCheck')
conditions = cherrypy.request.config.get('auth.require', None)
#logger.debug('Headers: %s' % (cherrypy.request.headers))
#logger.debug('Request params: %s' % (cherrypy.request.params))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment