Skip to content

Commit 4717bf5

Browse files
committed
Switch off using blank passwords for login
There is now a config.ini setting [web] login_empty_passwords to enable logins for users without a password set. By default it's off and every user must have a password.
1 parent 2ba59ff commit 4717bf5

File tree

5 files changed

+41
-2
lines changed

5 files changed

+41
-2
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ Fixed:
9494
- issue2551205 - Add support for specifying valid origins
9595
for api: xmlrpc/rest. Allows CORS to work with roundup
9696
backend. (John Rouillard)
97+
- new option added to config.ini: login_empty_passwords set to
98+
no by default. Setting this to yes allows a user with an
99+
empty password to login.
97100

98101
Features:
99102

doc/upgrading.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ backends. You may want to run ``roundup-admin -i tracker_home
6969
reindex`` if you want to index or search for longer words in your full
7070
text searches. Re-indexing make take some time.
7171

72+
Check new login_empty_passwords setting
73+
---------------------------------------
74+
75+
In this version of Roundup, users with a blank password are not
76+
allowed to login. Blank passwords have been allowed since 2002, but
77+
2022 is a different time. If you have a use case that requires a user
78+
to login without a password, set the ``login_empty_passwords`` setting
79+
in the ``web`` section of ``config.ini`` to ``yes``.
80+
7281
Check compression settings (optional)
7382
-------------------------------------
7483

roundup/cgi/actions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,8 @@ def verifyPassword(self, userid, givenpw):
13981398
db.user.set(userid, password=newpw)
13991399
db.commit()
14001400
return 1
1401-
if not givenpw and not stored:
1401+
# allow blank password
1402+
if db.config.WEB_LOGIN_EMPTY_PASSWORDS and not givenpw and not stored:
14021403
return 1
14031404
return 0
14041405

roundup/configuration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,9 @@ def str2value(self, value):
12601260
"Setting this option makes Roundup display error tracebacks\n"
12611261
"in the user's browser rather than emailing them to the\n"
12621262
"tracker admin."),
1263+
(BooleanOption, "login_empty_passwords", "no",
1264+
"Setting this option to yes/true allows users with an empty/blank\n"
1265+
"password to login to the web/http interfaces."),
12631266
(BooleanOption, "migrate_passwords", "yes",
12641267
"Setting this option makes Roundup migrate passwords with\n"
12651268
"an insecure password-scheme to a more secure scheme\n"

test/test_actions.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def setUp(self):
2727
self.client.db.Otk.getall = self.data_get
2828
self.client.db.Otk.set = self.data_set
2929
self.client.db.config.WEB_LOGIN_ATTEMPTS_MIN = 20
30+
self.client.db.config.WEB_LOGIN_EMPTY_PASSWORDS = 0
3031
self.client._ok_message = []
3132
self.client._error_message = []
3233
self.client.add_error_message = lambda x, escape=True: add_message(
@@ -371,6 +372,27 @@ def opendb(username):
371372

372373
self.assertLoginLeavesMessages([], 'foo', 'right')
373374

375+
def testBlankPasswordLogin(self):
376+
self.client.db.security.hasPermission = lambda *args, **kwargs: True
377+
378+
self.client.db.user.get = lambda a,b: None
379+
380+
def opendb(username):
381+
self.assertEqual(username, 'blank')
382+
self.client.opendb = opendb
383+
384+
self.assertEqual(self.client.db.config.WEB_LOGIN_EMPTY_PASSWORDS, 0)
385+
self.assertLoginLeavesMessages(['Invalid login'], 'blank', '' )
386+
387+
self.client.db.config.WEB_LOGIN_EMPTY_PASSWORDS = 1
388+
self.form.value[:] = [] # reset form
389+
self.client._error_message = [] # reset errors
390+
self.assertLoginLeavesMessages([], 'blank', '' )
391+
392+
# reset
393+
self.client.db.user.get = lambda a,b: 'right'
394+
self.client.db.config.WEB_LOGIN_EMPTY_PASSWORDS = 0
395+
374396
def testCorrectLoginRedirect(self):
375397
self.client.db.security.hasPermission = lambda *args, **kwargs: True
376398
def opendb(username):
@@ -431,7 +453,8 @@ def testLoginRateLimit(self):
431453
'''
432454
# Do the first login setting an invalid login name
433455
self.assertLoginLeavesMessages(['Invalid login'], 'nouser')
434-
# use up the rest of the 20 login attempts
456+
# use up the rest of the 20 login attempts. Login name
457+
# persists.
435458
for i in range(19):
436459
self.client._error_message = []
437460
self.assertLoginLeavesMessages(['Invalid login'])

0 commit comments

Comments
 (0)