Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do check out Oli's links. You basically see the authenticated username as verified by Basic HTTP Authentication in Django by looking at request.META['REMOTE_USER'].</p> <p><strong>Update:</strong> Tested the proposed patch for ticket <a href="http://code.djangoproject.com/ticket/689" rel="noreferrer">#689</a>, which is available up-to-date in telenieko's git repository <a href="http://www.marcfargas.com/gitweb/?p=django.git;a=commitdiff_plain;h=trac/689-remote-user;hp=master" rel="noreferrer">here</a>. It applies cleanly at least on revision <a href="http://code.djangoproject.com/browser/django/trunk?rev=9084" rel="noreferrer">9084</a> of Django.</p> <p>Activate the remote user authentication backend by</p> <ul> <li>adding the <code>RemoteUserAuthMiddleware</code> after <code>AuthenticationMiddleware</code></li> <li>adding the setting <code>AUTHENTICATION_BACKENDS = ('django.contrib.auth.backends.RemoteUserAuthBackend',)</code></li> </ul> <p>If you use lighttpd and FastCGI like I do, activate mod_auth, create credentials for a test user (I called it <code>testuser</code> and set <code>123</code> as the password) and configure the Django site to require basic authentication.</p> <p>The following <code>urls.py</code> can be used to test the setup:</p> <pre><code>from django.conf.urls.defaults import * from django.http import HttpResponse from django.contrib.auth.models import User urlpatterns = patterns('', url(regex='^$', view=lambda request: HttpResponse(repr(request), 'text/plain')), url(regex='^user/$', view=lambda request: HttpResponse(repr(request.user), 'text/plain')), url(regex='^users/$', view=lambda request: HttpResponse( ','.join(u.username for u in User.objects.all()), 'text/plain')), ) </code></pre> <p>After reloading lighty and the Django FCGI server, loading the root of the site now asks for authentication and accepts the <code>testuser</code> credentials, and then outputs a dump of the request object. In request.META these new properties should be present:</p> <pre><code>'AUTH_TYPE': 'Basic' 'HTTP_AUTHORIZATION': 'Basic dGVzdHVzZXI6MTIz' 'REMOTE_USER': 'testuser' </code></pre> <p>The <code>/user/</code> URL can be used to check that you're indeed logged in as <code>testuser</code>:</p> <pre><code>&lt;User: testuser&gt; </code></pre> <p>And the <code>/users/</code> URL now lists the automatically added <code>testuser</code> (here the <code>admin</code> user I had created when doing <code>syncdb</code> is also shown):</p> <pre><code>admin,testuser </code></pre> <p>If you don't want to patch Django, it's trivial to detach the <code>RemoteUserAuthBackend</code> and <code>RemoteUserAuthMiddleware</code> classes into a separate module and refer to that in the Django settings.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload