incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [42/50] git commit: Fix LDAP auth plugin
Date Wed, 23 Oct 2013 12:57:19 GMT
Fix LDAP auth plugin

- Added missing methods to the LDAP auth plugin
- New config option auth.ldap.use_schroot to enable/disable
  schroot - this disables SSH key uploads and shells, which
  is usefull for some deployments/testing
- The default value for auth.ldap.use_schroot is True, so the
  default behaviour should be unchaged


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/5ee1e72e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/5ee1e72e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/5ee1e72e

Branch: refs/heads/tv/6610
Commit: 5ee1e72e0acf6fee9781848367d8094402dfd657
Parents: b4945f0
Author: Rui Ferreira <rferreira@av.it.pt>
Authored: Wed Sep 4 16:01:10 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Mon Oct 21 18:31:09 2013 +0000

----------------------------------------------------------------------
 Allura/allura/lib/plugin.py | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/5ee1e72e/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 8e24cb2..3d8610d 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -49,6 +49,7 @@ from ming.orm import ThreadLocalORMSession
 from allura.lib import helpers as h
 from allura.lib import security
 from allura.lib import exceptions as forge_exc
+from paste.deploy.converters import asbool
 
 log = logging.getLogger(__name__)
 
@@ -291,18 +292,23 @@ class LdapAuthenticationProvider(AuthenticationProvider):
                 log.exception('Trying to create existing user %s', uname)
                 raise
             con.unbind_s()
-            argv = ('schroot -d / -c %s -u root /ldap-userconfig.py init %s' % (
-                config['auth.ldap.schroot_name'], user_doc['username'])).split()
-            p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-            rc = p.wait()
-            if rc != 0:
-                log.error('Error creating home directory for %s',
-                          user_doc['username'])
+
+            if asbool(config.get('auth.ldap.use_schroot', True)):
+                argv = ('schroot -d / -c %s -u root /ldap-userconfig.py init %s' % (
+                    config['auth.ldap.schroot_name'], user_doc['username'])).split()
+                p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+                rc = p.wait()
+                if rc != 0:
+                    log.error('Error creating home directory for %s',
+                              user_doc['username'])
         except:
             raise
         return result
 
     def upload_sshkey(self, username, pubkey):
+            if not asbool(config.get('auth.ldap.use_schroot', True)):
+                raise NotImplemented, 'SSH keys are not supported'
+
             argv = ('schroot -d / -c %s -u root /ldap-userconfig.py upload %s' % (
                 config['auth.ldap.schroot_name'], username)).split() + [ pubkey ]
             p = subprocess.Popen(argv, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
@@ -340,6 +346,18 @@ class LdapAuthenticationProvider(AuthenticationProvider):
             raise exc.HTTPUnauthorized()
         return user
 
+    def user_project_shortname(self, user):
+        return 'u/' + user.username.replace('_', '-')
+
+    def user_by_project_shortname(self, shortname):
+        from allura import model as M
+        return M.User.query.get(username=shortname)
+
+    def user_registration_date(self, user):
+        if user._id:
+            return user._id.generation_time
+        return datetime.utcnow()
+
 class ProjectRegistrationProvider(object):
     '''
     Project registration services for Allura.  This is a full implementation


Mime
View raw message