You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2016/09/08 16:29:27 UTC
[1/2] allura git commit: [#8125] delete unused file (from openid
login days)
Repository: allura
Updated Branches:
refs/heads/db/8125 [created] 123b27758
[#8125] delete unused file (from openid login days)
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/0e40b03c
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/0e40b03c
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/0e40b03c
Branch: refs/heads/db/8125
Commit: 0e40b03c42ec2667c622a218c1d1a9f69f382bfb
Parents: 9ecc626
Author: Dave Brondsema <da...@brondsema.net>
Authored: Thu Sep 8 12:25:20 2016 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Thu Sep 8 12:25:20 2016 -0400
----------------------------------------------------------------------
Allura/allura/templates/custom_login.html | 29 --------------------------
1 file changed, 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/0e40b03c/Allura/allura/templates/custom_login.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/custom_login.html b/Allura/allura/templates/custom_login.html
deleted file mode 100644
index 94f130b..0000000
--- a/Allura/allura/templates/custom_login.html
+++ /dev/null
@@ -1,29 +0,0 @@
-{#-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--#}
-{% extends g.theme.master %}
-
-{% block title %}{{title}}{% endblock %}
-
-{% block header %}{{prompt}}{% endblock %}
-
-{% block content %}
- <div id="loginform">
- {{form|safe}}
- </div>
-{% endblock %}
[2/2] allura git commit: [#8125] require user to be logged in to
their account to verify a new email address
Posted by br...@apache.org.
[#8125] require user to be logged in to their account to verify a new email address
Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/123b2775
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/123b2775
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/123b2775
Branch: refs/heads/db/8125
Commit: 123b27758d9f9b0129581c0a856c51280ef36deb
Parents: 0e40b03
Author: Dave Brondsema <da...@brondsema.net>
Authored: Thu Sep 8 12:26:05 2016 -0400
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Thu Sep 8 12:26:05 2016 -0400
----------------------------------------------------------------------
Allura/allura/controllers/auth.py | 19 +++++++++++---
Allura/allura/tests/functional/test_auth.py | 33 +++++++++++++++++++++++-
2 files changed, 48 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/allura/blob/123b2775/Allura/allura/controllers/auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 382f4b1..067e4aa 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -260,13 +260,26 @@ class AuthController(BaseController):
flash('No such address', 'error')
redirect(request.referer)
- def _verify_addr(self, addr):
+ def _verify_addr(self, addr, do_auth_check=True):
confirmed_by_other = M.EmailAddress.find(dict(email=addr.email, confirmed=True)).all() if addr else []
confirmed_by_other = filter(lambda item: item != addr, confirmed_by_other)
if addr and not confirmed_by_other:
- addr.confirmed = True
user = addr.claimed_by_user(include_pending=True)
+ if do_auth_check and not user.pending:
+ # pending is ok, since you can't be logged in to your account yet :)
+ require_authenticated()
+ if c.user != user:
+ flash('You must be logged in to the correct account', 'warning')
+ # raising HTTPUnauthorized does this same logic, but doesn't preserve the flash() message
+ # so we have to do similar logic as LoginRedirectMiddleware right here
+ login_url = tg.config.get('auth.login_url', '/auth/')
+ return_to = request.environ['PATH_INFO']
+ if request.environ.get('QUERY_STRING'):
+ return_to += '?' + request.environ['QUERY_STRING']
+ redirect(login_url, {'return_to': return_to})
+
+ addr.confirmed = True
flash('Email address confirmed')
h.auditlog_user('Email address verified: %s', addr.email, user=user)
if(user.get_pref('email_address') == None):
@@ -549,7 +562,7 @@ class PreferencesController(BaseController):
if not admin:
em.send_verification_link()
else:
- AuthController()._verify_addr(em)
+ AuthController()._verify_addr(em, do_auth_check=False)
else:
em.send_claim_attempt()
http://git-wip-us.apache.org/repos/asf/allura/blob/123b2775/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 261b956..4d35135 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -67,7 +67,7 @@ class TestAuth(TestController):
ThreadLocalORMSession.flush_all()
r = self.app.get('/auth/verify_addr', params=dict(a='foo'))
assert json.loads(self.webflash(r))['status'] == 'error', self.webflash(r)
- ea = M.EmailAddress.find().first()
+ ea = M.EmailAddress.find({'email': email}).first()
r = self.app.get('/auth/verify_addr', params=dict(a=ea.nonce))
assert json.loads(self.webflash(r))['status'] == 'ok', self.webflash(r)
r = self.app.get('/auth/logout')
@@ -357,6 +357,37 @@ class TestAuth(TestController):
email = M.EmailAddress.find(dict(email=email_address, claimed_by_user_id=user._id)).first()
assert not email.confirmed
+ def test_verify_addr_correct_session(self):
+ self.app.get('/') # establish session
+ email_address = 'test_abcd@domain.net'
+
+ # test-user claimed email address
+ user = M.User.query.get(username='test-user')
+ user.claim_address(email_address)
+ email = M.EmailAddress.find(dict(email=email_address, claimed_by_user_id=user._id)).first()
+ email.confirmed = False
+ ThreadLocalORMSession.flush_all()
+
+ self.app.post('/auth/send_verification_link',
+ params=dict(a=email_address,
+ _session_id=self.app.cookies['_session_id']),
+ extra_environ=dict(username='test-user'))
+
+ # logged out, gets redirected to login page
+ r = self.app.get('/auth/verify_addr', params=dict(a=email.nonce), extra_environ=dict(username='*anonymous'))
+ assert_in('/auth/?return_to=%2Fauth%2Fverify_addr', r.location)
+
+ # logged in as someone else
+ r = self.app.get('/auth/verify_addr', params=dict(a=email.nonce), extra_environ=dict(username='test-admin'))
+ assert_in('/auth/?return_to=%2Fauth%2Fverify_addr', r.location)
+ assert_equal('You must be logged in to the correct account', json.loads(self.webflash(r))['message'])
+ assert_equal('warning', json.loads(self.webflash(r))['status'])
+
+ # logged in as correct user
+ r = self.app.get('/auth/verify_addr', params=dict(a=email.nonce), extra_environ=dict(username='test-user'))
+ assert_in('confirmed', json.loads(self.webflash(r))['message'])
+ assert_equal('ok', json.loads(self.webflash(r))['status'])
+
@staticmethod
def _create_password_reset_hash():
""" Generates a password reset token for a given user.