You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by cc...@apache.org on 2026/08/03 16:42:09 UTC
(allura) branch cc/11578 created (now 36f3fb2c4)
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a change to branch cc/11578
in repository https://gitbox.apache.org/repos/asf/allura.git
at 36f3fb2c4 SF-11578 Reject untracked Allura sessions
This branch includes the following new commits:
new 36f3fb2c4 SF-11578 Reject untracked Allura sessions
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(allura) 01/01: SF-11578 Reject untracked Allura sessions
Posted by cc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch cc/11578
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 36f3fb2c41c3de0ae83cae4f5e5b0ab2f84b4e51
Author: Carlos Cruz <ca...@slashdotmedia.com>
AuthorDate: Mon Jul 27 22:52:29 2026 -0600
SF-11578 Reject untracked Allura sessions
---
Allura/allura/lib/plugin.py | 8 +++++---
Allura/allura/tests/functional/test_auth.py | 25 +++++++++++++++----------
2 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/Allura/allura/lib/plugin.py b/Allura/allura/lib/plugin.py
index 2e4e59956..4c8e470ea 100644
--- a/Allura/allura/lib/plugin.py
+++ b/Allura/allura/lib/plugin.py
@@ -169,11 +169,13 @@ def authenticate_request(self):
if self.session.get('pwd-expired') and request.path not in self.pwd_expired_allowed_urls:
redirect(h.url_return_to(self.pwd_expired_allowed_urls[0], self.request))
- # track session for already logged-in users to prevent them from being logged out
- if user and not user.is_anonymous() and not user.has_active_sessions():
+ reject_untracked_sessions = asbool(config.get('auth.reject_untracked_sessions', False))
+
+ # Preserve existing sessions when enforcement is disabled, but never bootstrap a session while enforcing.
+ if user and not user.is_anonymous() and not reject_untracked_sessions and not user.has_active_sessions():
user.track_session(self.session.id)
- if asbool(config.get('auth.reject_untracked_sessions', False)) and not user.validate_session(self.session.id):
+ if reject_untracked_sessions and not user.validate_session(self.session.id):
# calling self.logout() would break csrf so we just need to invalidate the session?
log.info(f'Session ID is not tracked: {self.session.id}')
self.session.invalidate()
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 85825af98..5fff79886 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -3746,11 +3746,14 @@ def test_navigation(self):
user = M.User.by_username('test-user')
user.set_tool_data('web_session', ids=[])
- # Now that sessions for logged in users are tracked, navigating to a page without a session id should no longer
- # redirect to the login page
- r = self.app.get('/auth/preferences/', extra_environ={'username': 'test-user'})
- assert r.status_code == 200
- assert 'User Preferences for test-user' in r.text
+ # An empty allowlist must revoke an existing session when enforcement is enabled.
+ r = self.app.get('/auth/preferences/',
+ extra_environ={'username': 'test-user', 'disable_auth_magic': 'True'},
+ status=302)
+ assert '/auth/?return_to=%2Fauth%2Fpreferences%2F' in r.location
+
+ user = M.User.by_username('test-user')
+ assert user.get_tool_data('web_session', 'ids') == []
@mock.patch.dict(config, {'auth.reject_untracked_sessions': True})
def test_navigation_with_invalid_session(self):
@@ -3787,19 +3790,21 @@ def test_sessions_max_limit(self):
assert session_ids[-1] == 1
@mock.patch.dict(config, {'auth.reject_untracked_sessions': True})
- def test_track_session_already_logged_in(self):
+ def test_does_not_track_unlisted_session(self):
r = login(self.app)
session_id = r.session.id
user = M.User.by_username('test-user')
session_ids = user.get_tool_data('web_session', 'ids')
assert session_id in session_ids
- # Delete the tracked web session to simulate an already logged-in user at the time the feature is enabled
+ # Delete the tracked web session to simulate an already logged-in user at the time enforcement is enabled.
user.set_tool_data('web_session', ids=[])
- # Navigate to a page, a web session id should be created and tracked
- r = self.app.get('/auth/preferences/', extra_environ={'username': 'test-user'})
+ # Navigating must not recreate an allowlist entry for the existing session.
+ self.app.get('/auth/preferences/',
+ extra_environ={'username': 'test-user', 'disable_auth_magic': 'True'},
+ status=302)
user = M.User.by_username('test-user')
session_ids = user.get_tool_data('web_session', 'ids')
- assert len(session_ids) == 1
+ assert session_ids == []