Add COMMON_ALLOW_ANONYMOUS_ACCESS configuration option to allow access to non authenticated users
This commit is contained in:
@@ -64,3 +64,12 @@ register_setting(
|
||||
default=u'username',
|
||||
description=_(u'Controls the mechanism used to authenticated user. Options are: username, email'),
|
||||
)
|
||||
|
||||
register_setting(
|
||||
namespace=u'common',
|
||||
module=u'common.conf.settings',
|
||||
name=u'ALLOW_ANONYMOUS_ACCESS',
|
||||
global_name=u'COMMON_ALLOW_ANONYMOUS_ACCESS',
|
||||
default=False,
|
||||
description=_(u'Allows non authenticated users access to all views'),
|
||||
)
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import re
|
||||
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.conf import settings
|
||||
|
||||
from ..conf.settings import ALLOW_ANONYMOUS_ACCESS
|
||||
|
||||
EXEMPT_URLS = [re.compile(settings.LOGIN_URL.lstrip('/'))]
|
||||
if hasattr(settings, 'LOGIN_EXEMPT_URLS'):
|
||||
EXEMPT_URLS += [re.compile(expr) for expr in settings.LOGIN_EXEMPT_URLS]
|
||||
@@ -20,13 +24,14 @@ class LoginRequiredMiddleware:
|
||||
"""
|
||||
|
||||
def process_request(self, request):
|
||||
assert hasattr(request, 'user'), "The Login Required middleware\
|
||||
requires authentication middleware to be installed. Edit your\
|
||||
MIDDLEWARE_CLASSES setting to insert\
|
||||
'django.contrib.auth.middlware.AuthenticationMiddleware'. If that doesn't\
|
||||
work, ensure your TEMPLATE_CONTEXT_PROCESSORS setting includes\
|
||||
'django.core.context_processors.auth'."
|
||||
if not request.user.is_authenticated():
|
||||
path = request.path_info.lstrip('/')
|
||||
if not any(m.match(path) for m in EXEMPT_URLS):
|
||||
return HttpResponseRedirect(settings.LOGIN_URL)
|
||||
if not ALLOW_ANONYMOUS_ACCESS:
|
||||
assert hasattr(request, 'user'), "The Login Required middleware\
|
||||
requires authentication middleware to be installed. Edit your\
|
||||
MIDDLEWARE_CLASSES setting to insert\
|
||||
'django.contrib.auth.middlware.AuthenticationMiddleware'. If that doesn't\
|
||||
work, ensure your TEMPLATE_CONTEXT_PROCESSORS setting includes\
|
||||
'django.core.context_processors.auth'."
|
||||
if not request.user.is_authenticated():
|
||||
path = request.path_info.lstrip('/')
|
||||
if not any(m.match(path) for m in EXEMPT_URLS):
|
||||
return HttpResponseRedirect(settings.LOGIN_URL)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
Version 0.12
|
||||
------------
|
||||
* Added new configuration option COMMON_ALLOW_ANONYMOUS_ACCESS to allow
|
||||
non authenticated access.
|
||||
* Statistics fixes
|
||||
* Italian translation by SeeOpen.IT (www.seeopen.it, info@seeopen.it)
|
||||
* Removed the 'db_index' argument from Text fields definition and
|
||||
|
||||
@@ -188,7 +188,7 @@ Job processor
|
||||
Default: ``None``
|
||||
|
||||
|
||||
Specified which job processing library to use, option are: None and celery.
|
||||
Specifies which job processing library to use, option are: None and celery.
|
||||
|
||||
|
||||
Document indexing
|
||||
@@ -230,12 +230,17 @@ OCR
|
||||
.. data:: OCR_TESSERACT_PATH
|
||||
|
||||
Default: ``/bin/tesseract``
|
||||
|
||||
File path to the ``tesseract`` executable, used to perform OCR on document
|
||||
page's images.
|
||||
|
||||
|
||||
.. data:: OCR_TESSERACT_LANGUAGE
|
||||
|
||||
Default: ``eng``
|
||||
|
||||
|
||||
Language code passed to the ``tesseract`` executable.
|
||||
|
||||
|
||||
.. data:: OCR_REPLICATION_DELAY
|
||||
|
||||
@@ -256,7 +261,8 @@ OCR
|
||||
|
||||
Default: ``False``
|
||||
|
||||
Automatically queue newly created documents for OCR.
|
||||
Automatically queue newly created documents or newly uploaded versions
|
||||
of existing documents for OCR.
|
||||
|
||||
|
||||
.. data:: OCR_QUEUE_PROCESSING_INTERVAL
|
||||
@@ -277,7 +283,8 @@ OCR
|
||||
|
||||
Default: ``/usr/bin/unpaper``
|
||||
|
||||
File path to unpaper program.
|
||||
File path to the ``unpaper`` executable, used to clean up images before
|
||||
doing OCR.
|
||||
|
||||
|
||||
Metadata
|
||||
@@ -318,24 +325,39 @@ Common
|
||||
.. data:: COMMON_AUTO_CREATE_ADMIN
|
||||
|
||||
Default: ``True``
|
||||
|
||||
Automatically creates an administrator superuser with the username
|
||||
specified by COMMON_AUTO_ADMIN_USERNAME and with the default password
|
||||
specified by COMMON_AUTO_ADMIN_PASSWORD
|
||||
|
||||
|
||||
.. data:: COMMON_AUTO_ADMIN_USERNAME
|
||||
|
||||
Default: ``admin``
|
||||
|
||||
Username of the automatically created superuser
|
||||
|
||||
|
||||
.. data:: COMMON_AUTO_ADMIN_PASSWORD
|
||||
|
||||
Default: ``admin``
|
||||
|
||||
|
||||
Default password of the automatically created superuser
|
||||
|
||||
|
||||
.. data:: COMMON_LOGIN_METHOD
|
||||
|
||||
Default: ``username``
|
||||
|
||||
Controls the mechanism used to authenticated user. Options are: ``username``, ``email``
|
||||
|
||||
|
||||
.. data:: COMMON_ALLOW_ANONYMOUS_ACCESS
|
||||
|
||||
Default: ``False``
|
||||
|
||||
Allow non authenticated users, access to all views
|
||||
|
||||
|
||||
Search
|
||||
------
|
||||
|
||||
Reference in New Issue
Block a user