The branch, statusflag has been updated via 689eb8340b47a1188a1b628d244e001054a5ac35 (commit) from a0d62e0be475fa27152decbc15b009cdd937bb1d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: x2gobroker/{backends => authmechs}/__init__.py | 0 x2gobroker/{__init__.py => authmechs/base.py} | 5 +- x2gobroker/{__init__.py => authmechs/htpasswd.py} | 6 +- x2gobroker/{backends/ldap.py => authmechs/pam.py} | 17 ++--- .../{backends/ldap.py => authmechs/testsuite.py} | 16 ++--- x2gobroker/backends/base.py | 72 ++++++++------------ 6 files changed, 50 insertions(+), 66 deletions(-) copy x2gobroker/{backends => authmechs}/__init__.py (100%) copy x2gobroker/{__init__.py => authmechs/base.py} (90%) copy x2gobroker/{__init__.py => authmechs/htpasswd.py} (83%) copy x2gobroker/{backends/ldap.py => authmechs/pam.py} (74%) copy x2gobroker/{backends/ldap.py => authmechs/testsuite.py} (77%) The diff of changes is: diff --git a/x2gobroker/backends/__init__.py b/x2gobroker/authmechs/__init__.py similarity index 100% copy from x2gobroker/backends/__init__.py copy to x2gobroker/authmechs/__init__.py diff --git a/x2gobroker/__init__.py b/x2gobroker/authmechs/base.py similarity index 90% copy from x2gobroker/__init__.py copy to x2gobroker/authmechs/base.py index ad8c1e4..cf58d59 100644 --- a/x2gobroker/__init__.py +++ b/x2gobroker/authmechs/base.py @@ -18,6 +18,7 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -__VERSION__ = '0.0.0.1' - +class X2GoBrokerAuthMech(object): + def authenticate(self, username, password): + return False \ No newline at end of file diff --git a/x2gobroker/__init__.py b/x2gobroker/authmechs/htpasswd.py similarity index 83% copy from x2gobroker/__init__.py copy to x2gobroker/authmechs/htpasswd.py index ad8c1e4..0778ca0 100644 --- a/x2gobroker/__init__.py +++ b/x2gobroker/authmechs/htpasswd.py @@ -18,6 +18,10 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -__VERSION__ = '0.0.0.1' +class X2GoBrokerAuthMech(object): + def authenticate(self, username, password): + + ### TODO: implement an authentication mechanism that can use htpasswd files + return False diff --git a/x2gobroker/backends/ldap.py b/x2gobroker/authmechs/pam.py similarity index 74% copy from x2gobroker/backends/ldap.py copy to x2gobroker/authmechs/pam.py index 62b9801..77927f4 100644 --- a/x2gobroker/backends/ldap.py +++ b/x2gobroker/authmechs/pam.py @@ -18,16 +18,13 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -"""\ -X2goBrokerLDAP class - a production X2GoBroker implementations that uses LDAP as configuration backend +class X2GoBrokerAuthMech(object): -""" -__NAME__ = 'x2gobroker-pylib' + def authenticate(self, username, password): -# modules -import x2gobroker.base + # do a simple PAM authentication against the PAM service ,,x2gobroker'' + if username and password: + if pam.authenticate(username, password, service="x2gobroker"): + return True -class X2GoBroker(x2gobroker.base.X2GoBroker): - """\ - - """ + return False diff --git a/x2gobroker/backends/ldap.py b/x2gobroker/authmechs/testsuite.py similarity index 77% copy from x2gobroker/backends/ldap.py copy to x2gobroker/authmechs/testsuite.py index 62b9801..c2aea0b 100644 --- a/x2gobroker/backends/ldap.py +++ b/x2gobroker/authmechs/testsuite.py @@ -18,16 +18,12 @@ # Free Software Foundation, Inc., # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -"""\ -X2goBrokerLDAP class - a production X2GoBroker implementations that uses LDAP as configuration backend +class X2GoBrokerAuthMech(object): -""" -__NAME__ = 'x2gobroker-pylib' + def authenticate(self, username, password): -# modules -import x2gobroker.base + # return C{True} for user test with password sweet... (used by the unit tests) + if username == 'test' and password == 'sweet': + return True + return False -class X2GoBroker(x2gobroker.base.X2GoBroker): - """\ - - """ diff --git a/x2gobroker/backends/base.py b/x2gobroker/backends/base.py index f6f0dd6..fb27617 100644 --- a/x2gobroker/backends/base.py +++ b/x2gobroker/backends/base.py @@ -48,7 +48,8 @@ class X2GoBroker(object): """ backend_name = 'base' - service_module = None + nameservice_module = None + authmech_module = None def __init__(self, config_file=None, config_defaults=None): """\ @@ -280,36 +281,21 @@ class X2GoBroker(object): #} return 'OK' - def _auth_mech_testsuite(self, username='', password=''): - if username == 'test' and password == 'sweet': + def _import_authmech_module(self, mech='pam'): + try: + if self.authmech_module is None: + exec("import x2gobroker.authmechs.{mech} as _authmech_module".format(mech=mech)) + self.authmech_module = _authmech_module return True - - def _auth_mech_pam(self, username='', password=''): - - # do a simple PAM authentication against the PAM service ,,x2gobroker'' - if username and password: - if pam.authenticate(username, password, service="x2gobroker"): - return True - - def _auth_mech_htpasswd(self, username='', password=''): - - ### TODO: implement an authentication mechanism that can use htpasswd files - return False + except ImportError: + return False def _do_authenticate(self, username='', password=''): - _auth_mech = self.get_authentication_mechanism() - - if _auth_mech == 'pam': - return self._auth_mech_pam(username=username, password=password) - - elif _auth_mech == 'htpasswd': - return self._auth_mech_htpasswd(username=username, password=password) - - elif _auth_mech == 'testsuite': - return self._auth_mech_testsuite(username=username, password=password) - - return False + if self._import_authmech_module(mech=self.get_authentication_mechanism()): + return self.authmech_module.X2GoBrokerAuthMech().authenticate(username, password) + else: + return False def get_authentication_mechanism(self): """\ @@ -366,11 +352,11 @@ class X2GoBroker(object): return unicode(_group_db) - def _import_service_module(self, service='libnss'): + def _import_nameservice_module(self, service='libnss'): try: - if self.service_module is None: - exec("import x2gobroker.nameservices.{service} as _service_module".format(service=service)) - self.service_module = _service_module + if self.nameservice_module is None: + exec("import x2gobroker.nameservices.{service} as _nameservice_module".format(service=service)) + self.nameservice_module = _nameservice_module return True except ImportError: return False @@ -386,8 +372,8 @@ class X2GoBroker(object): @rtype: C{bool} """ - if self._import_service_module(service=self.get_userdb_service()): - return self.service_module.X2GoBrokerNameService().has_user(username=username) + if self._import_nameservice_module(service=self.get_userdb_service()): + return self.nameservice_module.X2GoBrokerNameService().has_user(username=username) else: return False @@ -399,8 +385,8 @@ class X2GoBroker(object): @rtype: C{list} """ - if self._import_service_module(service=self.get_userdb_service()): - return self.service_module.X2GoBrokerNameService().get_users() + if self._import_nameservice_module(service=self.get_userdb_service()): + return self.nameservice_module.X2GoBrokerNameService().get_users() else: return False @@ -415,8 +401,8 @@ class X2GoBroker(object): @rtype: C{bool} """ - if self._import_service_module(service=self.get_groupdb_service()): - return self.service_module.X2GoBrokerNameService().has_group(group=group) + if self._import_nameservice_module(service=self.get_groupdb_service()): + return self.nameservice_module.X2GoBrokerNameService().has_group(group=group) else: return False @@ -428,8 +414,8 @@ class X2GoBroker(object): @rtype: C{list} """ - if self._import_service_module(service=self.get_groupdb_service()): - return self.service_module.X2GoBrokerNameService().get_groups() + if self._import_nameservice_module(service=self.get_groupdb_service()): + return self.nameservice_module.X2GoBrokerNameService().get_groups() else: return False @@ -441,8 +427,8 @@ class X2GoBroker(object): @rtype: C{bool} """ - if self._import_service_module(service=self.get_groupdb_service()): - return self.service_module.X2GoBrokerNameService().is_group_member(username=username, group=group, primary_groups=primary_groups) + if self._import_nameservice_module(service=self.get_groupdb_service()): + return self.nameservice_module.X2GoBrokerNameService().is_group_member(username=username, group=group, primary_groups=primary_groups) else: return [] @@ -459,8 +445,8 @@ class X2GoBroker(object): @rtype: C{list} """ - if self._import_service_module(service=self.get_groupdb_service()): - return self.service_module.X2GoBrokerNameService().get_group_members(group=group, primary_groups=primary_groups) + if self._import_nameservice_module(service=self.get_groupdb_service()): + return self.nameservice_module.X2GoBrokerNameService().get_group_members(group=group, primary_groups=primary_groups) else: return [] hooks/post-receive -- x2gobroker.git (HTTP(S) Session broker for X2Go) This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).