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',
|
default=u'username',
|
||||||
description=_(u'Controls the mechanism used to authenticated user. Options are: username, email'),
|
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
|
import re
|
||||||
|
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
from ..conf.settings import ALLOW_ANONYMOUS_ACCESS
|
||||||
|
|
||||||
EXEMPT_URLS = [re.compile(settings.LOGIN_URL.lstrip('/'))]
|
EXEMPT_URLS = [re.compile(settings.LOGIN_URL.lstrip('/'))]
|
||||||
if hasattr(settings, 'LOGIN_EXEMPT_URLS'):
|
if hasattr(settings, 'LOGIN_EXEMPT_URLS'):
|
||||||
EXEMPT_URLS += [re.compile(expr) for expr in 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):
|
def process_request(self, request):
|
||||||
assert hasattr(request, 'user'), "The Login Required middleware\
|
if not ALLOW_ANONYMOUS_ACCESS:
|
||||||
requires authentication middleware to be installed. Edit your\
|
assert hasattr(request, 'user'), "The Login Required middleware\
|
||||||
MIDDLEWARE_CLASSES setting to insert\
|
requires authentication middleware to be installed. Edit your\
|
||||||
'django.contrib.auth.middlware.AuthenticationMiddleware'. If that doesn't\
|
MIDDLEWARE_CLASSES setting to insert\
|
||||||
work, ensure your TEMPLATE_CONTEXT_PROCESSORS setting includes\
|
'django.contrib.auth.middlware.AuthenticationMiddleware'. If that doesn't\
|
||||||
'django.core.context_processors.auth'."
|
work, ensure your TEMPLATE_CONTEXT_PROCESSORS setting includes\
|
||||||
if not request.user.is_authenticated():
|
'django.core.context_processors.auth'."
|
||||||
path = request.path_info.lstrip('/')
|
if not request.user.is_authenticated():
|
||||||
if not any(m.match(path) for m in EXEMPT_URLS):
|
path = request.path_info.lstrip('/')
|
||||||
return HttpResponseRedirect(settings.LOGIN_URL)
|
if not any(m.match(path) for m in EXEMPT_URLS):
|
||||||
|
return HttpResponseRedirect(settings.LOGIN_URL)
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
Version 0.12
|
Version 0.12
|
||||||
------------
|
------------
|
||||||
|
* Added new configuration option COMMON_ALLOW_ANONYMOUS_ACCESS to allow
|
||||||
|
non authenticated access.
|
||||||
* Statistics fixes
|
* Statistics fixes
|
||||||
* Italian translation by SeeOpen.IT (www.seeopen.it, info@seeopen.it)
|
* Italian translation by SeeOpen.IT (www.seeopen.it, info@seeopen.it)
|
||||||
* Removed the 'db_index' argument from Text fields definition and
|
* Removed the 'db_index' argument from Text fields definition and
|
||||||
|
|||||||
+25
-3
@@ -188,7 +188,7 @@ Job processor
|
|||||||
Default: ``None``
|
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
|
Document indexing
|
||||||
@@ -231,11 +231,16 @@ OCR
|
|||||||
|
|
||||||
Default: ``/bin/tesseract``
|
Default: ``/bin/tesseract``
|
||||||
|
|
||||||
|
File path to the ``tesseract`` executable, used to perform OCR on document
|
||||||
|
page's images.
|
||||||
|
|
||||||
|
|
||||||
.. data:: OCR_TESSERACT_LANGUAGE
|
.. data:: OCR_TESSERACT_LANGUAGE
|
||||||
|
|
||||||
Default: ``eng``
|
Default: ``eng``
|
||||||
|
|
||||||
|
Language code passed to the ``tesseract`` executable.
|
||||||
|
|
||||||
|
|
||||||
.. data:: OCR_REPLICATION_DELAY
|
.. data:: OCR_REPLICATION_DELAY
|
||||||
|
|
||||||
@@ -256,7 +261,8 @@ OCR
|
|||||||
|
|
||||||
Default: ``False``
|
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
|
.. data:: OCR_QUEUE_PROCESSING_INTERVAL
|
||||||
@@ -277,7 +283,8 @@ OCR
|
|||||||
|
|
||||||
Default: ``/usr/bin/unpaper``
|
Default: ``/usr/bin/unpaper``
|
||||||
|
|
||||||
File path to unpaper program.
|
File path to the ``unpaper`` executable, used to clean up images before
|
||||||
|
doing OCR.
|
||||||
|
|
||||||
|
|
||||||
Metadata
|
Metadata
|
||||||
@@ -319,16 +326,24 @@ Common
|
|||||||
|
|
||||||
Default: ``True``
|
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
|
.. data:: COMMON_AUTO_ADMIN_USERNAME
|
||||||
|
|
||||||
Default: ``admin``
|
Default: ``admin``
|
||||||
|
|
||||||
|
Username of the automatically created superuser
|
||||||
|
|
||||||
|
|
||||||
.. data:: COMMON_AUTO_ADMIN_PASSWORD
|
.. data:: COMMON_AUTO_ADMIN_PASSWORD
|
||||||
|
|
||||||
Default: ``admin``
|
Default: ``admin``
|
||||||
|
|
||||||
|
Default password of the automatically created superuser
|
||||||
|
|
||||||
|
|
||||||
.. data:: COMMON_LOGIN_METHOD
|
.. data:: COMMON_LOGIN_METHOD
|
||||||
|
|
||||||
@@ -337,6 +352,13 @@ Common
|
|||||||
Controls the mechanism used to authenticated user. Options are: ``username``, ``email``
|
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
|
Search
|
||||||
------
|
------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user