From 748d4bae4b9e93327cf18c2fde99b52c9c8d8208 Mon Sep 17 00:00:00 2001 From: Markos Gogoulos Date: Wed, 2 Jun 2021 17:18:06 +0300 Subject: [PATCH] Feat login required (#204) * global login required option * add option to require global login --- cms/settings.py | 13 +++++++++++++ requirements.txt | 3 +++ 2 files changed, 16 insertions(+) diff --git a/cms/settings.py b/cms/settings.py index 9064588..9964cd3 100644 --- a/cms/settings.py +++ b/cms/settings.py @@ -427,6 +427,10 @@ CELERY_BEAT_SCHEDULE = { LOCAL_INSTALL = False +# this is an option to make the whole portal available to logged in users only +# it is placed here so it can be overrided on local_settings.py +GLOBAL_LOGIN_REQUIRED = False + try: # keep a local_settings.py file for local overrides from .local_settings import * @@ -446,3 +450,12 @@ if LOCAL_INSTALL: SSL_FRONTEND_HOST = FRONTEND_HOST.replace("http", "https") else: SSL_FRONTEND_HOST = FRONTEND_HOST + +if GLOBAL_LOGIN_REQUIRED: + # this should go after the AuthenticationMiddleware middleware + MIDDLEWARE.insert(5, "login_required.middleware.LoginRequiredMiddleware") + LOGIN_REQUIRED_IGNORE_PATHS = [ + r'/accounts/login/$', + r'/accounts/logout/$', + r'/accounts/signup/$', + ] diff --git a/requirements.txt b/requirements.txt index f414021..0f3292a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,11 +29,14 @@ m3u8 django-ckeditor +django-login-required-middleware==0.6.1 + # extra nice utilities! rpdb tqdm ipython flake8 +pylint pep8 django-silk django-debug-toolbar