Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As @mipadi said, you can't use htaccess on Heroku, but you can create a middleware for that:</p> <pre><code>from django.conf import settings from django.http import HttpResponse from django.utils.translation import ugettext as _ def basic_challenge(realm=None): if realm is None: realm = getattr(settings, 'WWW_AUTHENTICATION_REALM', _('Restricted Access')) # TODO: Make a nice template for a 401 message? response = HttpResponse(_('Authorization Required'), mimetype="text/plain") response['WWW-Authenticate'] = 'Basic realm="%s"' % (realm) response.status_code = 401 return response def basic_authenticate(authentication): # Taken from paste.auth (authmeth, auth) = authentication.split(' ',1) if 'basic' != authmeth.lower(): return None auth = auth.strip().decode('base64') username, password = auth.split(':',1) AUTHENTICATION_USERNAME = getattr(settings, 'BASIC_WWW_AUTHENTICATION_USERNAME') AUTHENTICATION_PASSWORD = getattr(settings, 'BASIC_WWW_AUTHENTICATION_PASSWORD') return username == AUTHENTICATION_USERNAME and password == AUTHENTICATION_PASSWORD class BasicAuthenticationMiddleware(object): def process_request(self, request): if not getattr(settings, 'BASIC_WWW_AUTHENTICATION', False): return if 'HTTP_AUTHORIZATION' not in request.META: return basic_challenge() authenticated = basic_authenticate(request.META['HTTP_AUTHORIZATION']) if authenticated: return return basic_challenge() </code></pre> <p>Then you need to define in <code>settings.py</code>:</p> <pre><code>BASIC_WWW_AUTHENTICATION_USERNAME = "your user" BASIC_WWW_AUTHENTICATION_PASSWORD = "your pass" BASIC_WWW_AUTHENTICATION = True </code></pre>
    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. 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