X-Git-Url: http://git.cascardo.info/?p=cascardo%2Fipsilon.git;a=blobdiff_plain;f=ipsilon%2Flogin%2Fauthfas.py;h=d0b834acbed9ebfe79606ed9706c28520f6f00cd;hp=3697c1a7fbf2c62a696b9cc3739b445c4b9b4f02;hb=485baf6ee7a315d1af1086fe5b5da8cff6c4ba37;hpb=771b8fd095f3bcb922f761d297c62f1a56a997d5 diff --git a/ipsilon/login/authfas.py b/ipsilon/login/authfas.py index 3697c1a..d0b834a 100644 --- a/ipsilon/login/authfas.py +++ b/ipsilon/login/authfas.py @@ -1,11 +1,12 @@ -# Copyright (C) 2014 Ipsilon contributors, see COPYING file for license +# Copyright (C) 2014 Ipsilon project Contributors, for license see COPYING - -from ipsilon.info.common import InfoMapping -from ipsilon.login.common import LoginFormBase, LoginManagerBase +from ipsilon.login.common import LoginFormBase, LoginManagerBase, \ + LoginManagerInstaller from ipsilon.util.plugin import PluginObject +from ipsilon.util.policy import Policy from ipsilon.util import config as pconfig import cherrypy +import logging from fedora.client.fasproxy import FasProxyClient from fedora.client import AuthError @@ -27,22 +28,21 @@ try: except ImportError: CLA_GROUPS = dict() -fas_mapping = { - 'username': 'nickname', - 'telephone': 'phone', - 'country_code': 'country', - 'human_name': 'fullname', - 'email': 'email', - 'timezone': 'timezone', -} +fas_mapping = [ + ['username', 'nickname'], + ['telephone', 'phone'], + ['country_code', 'country'], + ['human_name', 'fullname'], + ['email', 'email'], + ['timezone', 'timezone'], +] class FAS(LoginFormBase): def __init__(self, site, mgr, page): super(FAS, self).__init__(site, mgr, page) - self.mapper = InfoMapping() - self.mapper.set_mapping(fas_mapping) + self.mapper = Policy(fas_mapping) def POST(self, *args, **kwargs): username = kwargs.get("login_name") @@ -54,9 +54,12 @@ class FAS(LoginFormBase): try: _, data = self.lm.fpc.login(username, password) except AuthError, e: - cherrypy.log.error("Authentication error [%s]" % str(e)) + cherrypy.log.error("Authentication error [%s]" % str(e), + severity=logging.ERROR) except Exception, e: # pylint: disable=broad-except - cherrypy.log.error("Unknown Error [%s]" % str(e)) + cherrypy.log.error("Unknown Error [%s]" % str(e), + severity=logging.ERROR) + if data and data.user: userdata = self.make_userdata(data.user) return self.lm.auth_successful(self.trans, @@ -64,10 +67,10 @@ class FAS(LoginFormBase): userdata=userdata) else: error = "Authentication failed" - cherrypy.log.error(error) + cherrypy.log.error(error, severity=logging.ERROR) else: error = "Username or password is missing" - cherrypy.log.error("Error: " + error) + cherrypy.log.error("Error: " + error, severity=logging.ERROR) context = self.create_tmpl_context( username=username, @@ -75,11 +78,11 @@ class FAS(LoginFormBase): error_password=not password, error_username=not username ) - # pylint: disable=star-args + self.lm.set_auth_error() return self._template(self.formtemplate, **context) def make_userdata(self, fas_data): - userdata, fas_extra = self.mapper.map_attrs(fas_data) + userdata, fas_extra = self.mapper.map_attributes(fas_data) # compute and store groups and cla groups userdata['_groups'] = [] @@ -171,18 +174,18 @@ Form based login Manager that uses the Fedora Authentication Server return self.page -class Installer(object): +class Installer(LoginManagerInstaller): def __init__(self, *pargs): + super(Installer, self).__init__() self.name = 'fas' - self.ptype = 'login' self.pargs = pargs def install_args(self, group): group.add_argument('--fas', choices=['yes', 'no'], default='no', help='Configure FAS authentication') - def configure(self, opts): + def configure(self, opts, changes): if opts['fas'] != 'yes': return