You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2014/10/06 12:42:50 UTC
[1/4] git commit: [#7221] set display_name for ldap autoregister;
decode unicode values from ldap
Repository: allura
Updated Branches:
refs/heads/master 5536ebee4 -> a0303fea4
[#7221] set display_name for ldap autoregister; decode unicode values from ldap
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/30f47316
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/30f47316
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/30f47316
Branch: refs/heads/master
Commit: 30f47316bb6b792169bbe8b385a50bb2aa58ab98
Parents: 5536ebe
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Fri Sep 26 01:52:33 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon Oct 6 09:12:59 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/plugin.py | 34 ++++++++++++--------
.../tests/unit/test_ldap_auth_provider.py | 23 ++++++++++++-
Allura/test.ini | 1 +
3 files changed, 43 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/30f47316/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 79eb1b9..f12529e 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -545,7 +545,9 @@ class LdapAuthenticationProvider(AuthenticationProvider):
if user is None:
if asbool(config.get('auth.ldap.autoregister', True)):
log.debug('LdapAuth: authorized user {} needs a mongo record registered. Creating...'.format(username))
- user = M.User.register({'username': username})
+ user = M.User.register({'username': username,
+ 'display_name': LdapUserPreferencesProvider()._get_pref(username, 'display_name'),
+ })
else:
log.debug('LdapAuth: no user {} found in local mongo'.format(username))
raise exc.HTTPUnauthorized()
@@ -1254,22 +1256,26 @@ class LdapUserPreferencesProvider(UserPreferencesProvider):
def get_pref(self, user, pref_name):
from allura import model as M
if pref_name in self.fields and user != M.User.anonymous():
- con = ldap_conn()
- try:
- rs = con.search_s(ldap_user_dn(user.username), ldap.SCOPE_BASE)
- except ldap.NO_SUCH_OBJECT:
- rs = []
- else:
- con.unbind_s()
- if not rs:
- log.warning('LdapUserPref: No user record found for: {}'.format(user.username))
- return ''
- user_dn, user_attrs = rs[0]
- ldap_attr = self.fields[pref_name]
- return user_attrs[ldap_attr][0] # assume single-valued list
+ self._get_pref(user.username, pref_name)
else:
return LocalUserPreferencesProvider().get_pref(user, pref_name)
+ def _get_pref(self, username, pref_name):
+ con = ldap_conn()
+ try:
+ rs = con.search_s(ldap_user_dn(username), ldap.SCOPE_BASE)
+ except ldap.NO_SUCH_OBJECT:
+ rs = []
+ else:
+ con.unbind_s()
+ if not rs:
+ log.warning('LdapUserPref: No user record found for: {}'.format(user.username))
+ return ''
+ user_dn, user_attrs = rs[0]
+ ldap_attr = self.fields[pref_name]
+ # assume single-valued list
+ return user_attrs[ldap_attr][0].decode('utf-8')
+
def set_pref(self, user, pref_name, pref_value):
if pref_name in self.fields:
con = ldap_conn()
http://git-wip-us.apache.org/repos/asf/allura/blob/30f47316/Allura/allura/tests/unit/test_ldap_auth_provider.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_ldap_auth_provider.py b/Allura/allura/tests/unit/test_ldap_auth_provider.py
index cc37b53..417f200 100644
--- a/Allura/allura/tests/unit/test_ldap_auth_provider.py
+++ b/Allura/allura/tests/unit/test_ldap_auth_provider.py
@@ -72,13 +72,34 @@ class TestLdapAuthenticationProvider(object):
self.provider.request.body = '&'.join(['%s=%s' % (k,v) for k,v in params.iteritems()])
ldap.dn.escape_dn_chars = lambda x: x
- dn = 'uid=%s,ou=users,dc=sf,dc=net' % params['username']
self.provider._login()
+
+ dn = 'uid=%s,ou=users,dc=sf,dc=net' % params['username']
ldap.initialize.assert_called_once_with('ldaps://localhost/')
connection = ldap.initialize.return_value
connection.bind_s.called_once_with(dn, 'test-password')
connection.unbind_s.assert_called_once()
+ @patch('allura.lib.plugin.ldap')
+ def test_login_autoregister(self, ldap):
+ # covers ldap get_pref too, via the display_name fetch
+ params = {
+ 'username': 'abc32590wr38',
+ 'password': 'test-password',
+ }
+ self.provider.request.method = 'POST'
+ self.provider.request.body = '&'.join(['%s=%s' % (k,v) for k,v in params.iteritems()])
+ ldap.dn.escape_dn_chars = lambda x: x
+ dn = 'uid=%s,ou=users,dc=sf,dc=net' % params['username']
+ conn = ldap.initialize.return_value
+ conn.search_s.return_value = [(dn, {'cn': [u'åℒƒ'.encode('utf-8')]})]
+
+ self.provider._login()
+
+ user = M.User.query.get(username=params['username'])
+ assert user
+ assert_equal(user.display_name, u'åℒƒ')
+
@patch('allura.lib.plugin.modlist')
@patch('allura.lib.plugin.ldap')
def test_register_user(self, ldap, modlist):
http://git-wip-us.apache.org/repos/asf/allura/blob/30f47316/Allura/test.ini
----------------------------------------------------------------------
diff --git a/Allura/test.ini b/Allura/test.ini
index 129c305..ecf1639 100644
--- a/Allura/test.ini
+++ b/Allura/test.ini
@@ -146,6 +146,7 @@ auth.ldap.use_schroot = False
auth.ldap.password.algorithm = 6
auth.ldap.password.rounds = 6000
auth.ldap.password.salt_len = 16
+user_prefs_storage.ldap.fields.display_name = cn
auth.allow_user_to_disable_account = true
auth.allow_edit_prefs = true
[3/4] git commit: [#7715] quoted the email address in the
verification url
Posted by je...@apache.org.
[#7715] quoted the email address in the verification url
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/3ebb5fc0
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/3ebb5fc0
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/3ebb5fc0
Branch: refs/heads/master
Commit: 3ebb5fc0ba6b40f588c889591d42f28c04ea9363
Parents: 6b97873
Author: Alexander Luberg <al...@slashdotmedia.com>
Authored: Tue Sep 30 10:44:42 2014 -0700
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon Oct 6 09:45:15 2014 +0000
----------------------------------------------------------------------
Allura/allura/templates/update_emails_form.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/3ebb5fc0/Allura/allura/templates/update_emails_form.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/update_emails_form.html b/Allura/allura/templates/update_emails_form.html
index 3ac5502..bc3cc33 100644
--- a/Allura/allura/templates/update_emails_form.html
+++ b/Allura/allura/templates/update_emails_form.html
@@ -42,7 +42,7 @@
{% if obj.confirmed %}
yes
{% else %}
- no (<a href="/auth/send_verification_link?a={{a}}">verify</a>)
+ no (<a href="/auth/send_verification_link?a={{h.urlquoteplus(a)}}">verify</a>)
{% endif %}
</td>
{% else %}
[2/4] git commit: [#7722] Limited /rest/u/USER to enabled users
Posted by je...@apache.org.
[#7722] Limited /rest/u/USER to enabled users
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/6b978734
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6b978734
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6b978734
Branch: refs/heads/master
Commit: 6b9787348db58d7b759d1570705c3e6104136b70
Parents: 30f4731
Author: Alexander Luberg <al...@slashdotmedia.com>
Authored: Fri Oct 3 15:05:22 2014 -0700
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon Oct 6 09:27:00 2014 +0000
----------------------------------------------------------------------
Allura/allura/controllers/rest.py | 7 +++++++
1 file changed, 7 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/6b978734/Allura/allura/controllers/rest.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index 3625032..1001343 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -261,6 +261,13 @@ class NeighborhoodRestController(object):
shortname=name, neighborhood_id=self._neighborhood._id, deleted=False)
if not project:
raise exc.HTTPNotFound, name
+
+ if project and name and name.startswith('u/'):
+ # make sure user-projects are associated with an enabled user
+ user = project.user_project_of
+ if not user or user.disabled:
+ raise exc.HTTPNotFound
+
c.project = project
return ProjectRestController(), remainder
[4/4] git commit: [#7221] Fix undefined variable error
Posted by je...@apache.org.
[#7221] Fix undefined variable error
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/a0303fea
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/a0303fea
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/a0303fea
Branch: refs/heads/master
Commit: a0303fea4fc941a612df893baf29bebd6e9e426c
Parents: 3ebb5fc
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Oct 6 09:59:12 2014 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon Oct 6 09:59:12 2014 +0000
----------------------------------------------------------------------
Allura/allura/lib/plugin.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/a0303fea/Allura/allura/lib/plugin.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index f12529e..e15e4c0 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -1269,7 +1269,7 @@ class LdapUserPreferencesProvider(UserPreferencesProvider):
else:
con.unbind_s()
if not rs:
- log.warning('LdapUserPref: No user record found for: {}'.format(user.username))
+ log.warning('LdapUserPref: No user record found for: {}'.format(username))
return ''
user_dn, user_attrs = rs[0]
ldap_attr = self.fields[pref_name]