Skip to content

Commit da3143e

Browse files
author
Richard Jones
committed
enabled disabling of REMOTE_USER for when it's not a valid username
[SF#1190187]
1 parent 1bc2f97 commit da3143e

File tree

3 files changed

+38
-27
lines changed

3 files changed

+38
-27
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Fixed:
1616
- fix handling of invalid interval input
1717
- search locale files relative ro roundup installation path (sf bug 1219689)
1818
- use translation for boolean property rendering (sf bug 1225152)
19+
- enabled disabling of REMOTE_USER for when it's not a valid username (sf
20+
bug 1190187)
1921

2022

2123
2005-05-02 0.8.3

roundup/cgi/client.py

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.213 2005-04-13 03:38:23 richard Exp $
1+
# $Id: client.py,v 1.214 2005-06-24 05:22:03 richard Exp $
22

33
"""WWW request handler (also used in the stand-alone server).
44
"""
@@ -397,32 +397,33 @@ def determine_user(self):
397397

398398
# first up, try the REMOTE_USER var (from HTTP Basic Auth handled
399399
# by a front-end HTTP server)
400-
if self.env.has_key('REMOTE_USER'):
401-
user = self.env['REMOTE_USER']
402-
else:
403-
user = 'anonymous'
400+
use_http_auth = self.instance.config['WEB_HTTP_AUTH'] == 'yes'
401+
user = 'anonymous'
402+
if use_http_auth:
403+
if self.env.has_key('REMOTE_USER'):
404+
user = self.env['REMOTE_USER']
405+
# try handling Basic Auth ourselves
406+
elif self.env.get('HTTP_AUTHORIZATION', ''):
407+
auth = self.env['HTTP_AUTHORIZATION']
408+
scheme, challenge = auth.split(' ', 1)
409+
if scheme.lower() == 'basic':
410+
try:
411+
decoded = base64.decodestring(challenge)
412+
except TypeError:
413+
# invalid challenge
414+
pass
415+
username, password = decoded.split(':')
416+
try:
417+
login = self.get_action_class('login')(self)
418+
login.verifyLogin(username, password)
419+
except LoginError, err:
420+
self.make_user_anonymous()
421+
self.response_code = 403
422+
raise Unauthorised, err
423+
424+
user = username
404425

405-
# try handling Basic Auth ourselves
406-
if (user == 'anonymous') and self.env.get('HTTP_AUTHORIZATION', ''):
407-
scheme, challenge = self.env['HTTP_AUTHORIZATION'].split(' ', 1)
408-
if scheme.lower() == 'basic':
409-
try:
410-
decoded = base64.decodestring(challenge)
411-
except TypeError:
412-
# invalid challenge
413-
pass
414-
username, password = decoded.split(':')
415-
try:
416-
self.get_action_class('login')(self).verifyLogin(
417-
username, password)
418-
except LoginError, err:
419-
self.make_user_anonymous()
420-
self.response_code = 403
421-
raise Unauthorised, err
422-
423-
user = username
424-
425-
# look up the user session cookie (may override the REMOTE_USER)
426+
# look up the user session cookie (may override the HTTP Basic Auth)
426427
cookie = self.cookie
427428
if (cookie.has_key(self.cookie_name) and
428429
cookie[self.cookie_name].value != 'deleted'):

roundup/configuration.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Roundup Issue Tracker configuration support
22
#
3-
# $Id: configuration.py,v 1.25 2005-02-14 02:48:10 richard Exp $
3+
# $Id: configuration.py,v 1.26 2005-06-24 05:22:03 richard Exp $
44
#
55
__docformat__ = "restructuredtext"
66

@@ -467,6 +467,14 @@ class NullableFilePathOption(NullableOption, FilePathOption):
467467
"by OS environment variable LANGUAGE, LC_ALL, LC_MESSAGES,\n"
468468
"or LANG, in that order of preference."),
469469
)),
470+
("web", (
471+
(Option, 'http_auth', "yes",
472+
"Whether to use HTTP Basic Authentication, if present.\n"
473+
"Roundup will use either the REMOTE_USER or HTTP_AUTHORIZATION\n"
474+
"variables supplied by your web server (in that order).\n"
475+
"Set this option to 'no' if you do not wish to use HTTP Basic\n"
476+
"Authentication in your web interface."),
477+
)),
470478
("rdbms", (
471479
(Option, 'name', 'roundup',
472480
"Name of the database to use.",

0 commit comments

Comments
 (0)