Review Board

beta

Improvements for authentication using REMOTE_USER

Updated 6 months, 3 weeks ago

Xavier Duret Reviewers
reviewboard
513 chipx86
None Review Board SVN
This patch aims to increase awareness of a specific need related to the use of Review Board in a corporate environment: the use of single sign on logins. In this case, the user authenticates once and the Apache server communicates the user name to Review board through Django. There is no more need for login and logout links as authentication is done when the user logs in its terminal or through its browser.

Because the current patch waiting for inclusion into Django's repository does not provide for a system to detect that web authentication is performed, a new variable called WEBAUTH is introduced in "settings". Its use in the template is straightforward. The manner in which the detection of web authentication is inelegant. Maybe this patch can be improved or maybe it is preferable to improve the patch for Django.
The change (with commented out code activated) have been deployed on my company servers which runs with the latest patch (t689-r7609.diff) for Django ticket #689. Review board is installed on a Centos 5 Apache box. It works properly.

Diff revision 2 (Latest)

1 2
1 2

  1. trunk/reviewboard/settings.py: 3 changes [ 1 2 3 ]
  2. trunk/reviewboard/templates/base.html: 5 changes [ 1 2 3 4 5 ]
  3. trunk/reviewboard/templates/accounts/prefs.html: 2 changes [ 1 2 ]
trunk/reviewboard/settings.py
Revision 1388 New Change
40
    'django.middleware.common.CommonMiddleware',
40
    'django.middleware.common.CommonMiddleware',
41
    'django.middleware.doc.XViewMiddleware',
41
    'django.middleware.doc.XViewMiddleware',
42
    'django.middleware.locale.LocaleMiddleware',
42
    'django.middleware.locale.LocaleMiddleware',
43
    'django.contrib.sessions.middleware.SessionMiddleware',
43
    'django.contrib.sessions.middleware.SessionMiddleware',
44
    'django.contrib.auth.middleware.AuthenticationMiddleware',
44
    'django.contrib.auth.middleware.AuthenticationMiddleware',
45
# The following line can be uncommented once Django ticket #689 is resolved
46
#    'django.contrib.auth.middleware.RemoteUserAuthMiddleware',
45
)
47
)
46
48
47
TEMPLATE_CONTEXT_PROCESSORS = (
49
TEMPLATE_CONTEXT_PROCESSORS = (
48
    'django.core.context_processors.auth',
50
    'django.core.context_processors.auth',
49
    'django.core.context_processors.debug',
51
    'django.core.context_processors.debug',
50
    'django.core.context_processors.i18n',
52
    'django.core.context_processors.i18n',
51
    'django.core.context_processors.media',
53
    'django.core.context_processors.media',
52
    'django.core.context_processors.request',
54
    'django.core.context_processors.request',
53
    'djblets.util.context_processors.settingsVars',
55
    'djblets.util.context_processors.settingsVars',
54
    'djblets.util.context_processors.siteRoot',
56
    'djblets.util.context_processors.siteRoot',
55
)
57
)
56
58
59
# Uncomment the following lines if you wish to use the authentication
60
# provided by the web server.
61
#AUTHENTICATION_BACKENDS = ( 
62
#    'django.contrib.auth.backends.RemoteUserAuthBackend',
63
#)
64
#REMOTE_USER_AUTH_AUTO_CREATE = True
65
57
SITE_ROOT_URLCONF = 'reviewboard.urls'
66
SITE_ROOT_URLCONF = 'reviewboard.urls'
58
ROOT_URLCONF = 'djblets.util.rooturl'
67
ROOT_URLCONF = 'djblets.util.rooturl'
59
68
60
REVIEWBOARD_ROOT = os.path.abspath(os.path.split(__file__)[0])
69
REVIEWBOARD_ROOT = os.path.abspath(os.path.split(__file__)[0])
61
70
99
# Whether to use django's built-in system for users.  This turns on certain
108
# Whether to use django's built-in system for users.  This turns on certain
100
# features like the registration page and profile editing.  If you're tying
109
# features like the registration page and profile editing.  If you're tying
101
# reviewboard in to an existing authentication environment (such as NIS),
110
# reviewboard in to an existing authentication environment (such as NIS),
102
# this data will come in from outside.
111
# this data will come in from outside.
103
BUILTIN_AUTH = True
112
BUILTIN_AUTH = True
113
WEBAUTH = ('django.contrib.auth.backends.RemoteUserAuthBackend' in AUTHENTICATION_BACKENDS)
104
AUTH_PROFILE_MODULE = "accounts.Profile"
114
AUTH_PROFILE_MODULE = "accounts.Profile"
105
115
106
# Default repository path to use for the source code.
116
# Default repository path to use for the source code.
107
DEFAULT_REPOSITORY_PATH = None
117
DEFAULT_REPOSITORY_PATH = None
108
118
trunk/reviewboard/templates/base.html
Revision 1388 New Change
41
     {% blocktrans with user|realname|escape as username %}<li>Welcome, <b>{{username}}</b></li>{% endblocktrans %}
41
     {% blocktrans with user|realname|escape as username %}<li>Welcome, <b>{{username}}</b></li>{% endblocktrans %}
42
     <li>- <a href="{% url user-preferences %}">{% trans "My account" %}</a></li>
42
     <li>- <a href="{% url user-preferences %}">{% trans "My account" %}</a></li>
43
{% if user.is_staff %}
43
{% if user.is_staff %}
44
     <li>- <a href="{% url django.contrib.admin.views.main.index %}">{% trans "Admin" %}</a></li>
44
     <li>- <a href="{% url django.contrib.admin.views.main.index %}">{% trans "Admin" %}</a></li>
45
{% endif %}
45
{% endif %}
46
     {% if not settings.WEBAUTH %}
46
     <li>- <a href="{% url logout %}">{% trans "Log out" %}</a></li>
47
     <li>- <a href="{% url logout %}">{% trans "Log out" %}</a></li>
48
     {% endif %}
47
    {% else %}
49
    {% else %}
50
     {% if not settings.WEBAUTH %}
48
     <li><a href="{% url login %}?next_page={{request.path}}">{% trans "Log in" %}</a></li>
51
     <li><a href="{% url login %}?next_page={{request.path}}">{% trans "Log in" %}</a></li>
49
     {% if settings.BUILTIN_AUTH %}
52
     {% endif %}
53
     {% if settings.BUILTIN_AUTH and not settings.WEBAUTH %}
50
     <li>- <a href="{% url register %}">{% trans "Register" %}</a></li>
54
     <li>- <a href="{% url register %}">{% trans "Register" %}</a></li>
51
     {% endif %}
55
     {% endif %}
52
    {% endif %}
56
    {% endif %}
53
     <li>- <a href="http://code.google.com/p/reviewboard/issues/list">{% trans "Bugs" %}</a></li>
57
     <li>- <a href="http://code.google.com/p/reviewboard/issues/list">{% trans "Bugs" %}</a></li>
54
     <li>- <a href="http://code.google.com/p/reviewboard/issues/entry">{% trans "Report bug" %}</a></li>
58
     <li>- <a href="http://code.google.com/p/reviewboard/issues/entry">{% trans "Report bug" %}</a></li>
trunk/reviewboard/templates/accounts/prefs.html
Revision 1388 New Change
34
   </tr>
34
   </tr>
35
   <tr>
35
   <tr>
36
    <td><label for="id_email">{% trans "Email:" %}</label></td>
36
    <td><label for="id_email">{% trans "Email:" %}</label></td>
37
    <td>{{form.email}} {{form.errors.email}}</td>
37
    <td>{{form.email}} {{form.errors.email}}</td>
38
   </tr>
38
   </tr>
39
   {% if not settings.WEBAUTH %}
39
   <tr>
40
   <tr>
40
    <td><label for="id_password">{% trans "Change Password:" %}</label></td>
41
    <td><label for="id_password">{% trans "Change Password:" %}</label></td>
41
    <td>{{form.password1}}</td>
42
    <td>{{form.password1}}</td>
42
   </tr>
43
   </tr>
43
   <tr>
44
   <tr>
44
    <td><label for="id_password2">{% trans "Verify New Password:" %}</label></td>
45
    <td><label for="id_password2">{% trans "Verify New Password:" %}</label></td>
45
    <td>{{form.password2}} {{form.errors.password2}}</td>
46
    <td>{{form.password2}} {{form.errors.password2}}</td>
46
   </tr>
47
   </tr>
47
   {% endif %}
48
   {% endif %}
49
   {% endif %}
48
{% if settings.DIFF_SYNTAX_HIGHLIGHTING %}
50
{% if settings.DIFF_SYNTAX_HIGHLIGHTING %}
49
   <tr>
51
   <tr>
50
    <td></td>
52
    <td></td>
51
    <td>{{form.syntax_highlighting}} {{form.syntax_highlighting.label}}</td>
53
    <td>{{form.syntax_highlighting}} {{form.syntax_highlighting.label}}</td>
52
   </tr>
54
   </tr>
  1. trunk/reviewboard/settings.py: 3 changes [ 1 2 3 ]
  2. trunk/reviewboard/templates/base.html: 5 changes [ 1 2 3 4 5 ]
  3. trunk/reviewboard/templates/accounts/prefs.html: 2 changes [ 1 2 ]