From 573a522e34bef8ff9bb44df856d77d732bb216a4 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 18 Sep 2024 07:47:44 -0700 Subject: [PATCH] Enhancement: allow setting session cookie age --- docs/configuration.md | 7 +++++++ src/paperless/settings.py | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index 3530849dd..16e4d8f03 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -611,6 +611,13 @@ You can optionally also automatically redirect users to the SSO login with [PAPE : Only applies to regular (non-SSO) accounts. See the corresponding [django-allauth documentation](https://docs.allauth.org/en/latest/account/configuration.html) +#### [`PAPERLESS_SESSION_COOKIE_AGE=`](#PAPERLESS_SESSION_COOKIE_AGE) {#PAPERLESS_SESSION_COOKIE_AGE} + +: Applies to all logins. See the corresponding +[django documentation](https://docs.djangoproject.com/en/5.1/ref/settings/#std-setting-SESSION_COOKIE_AGE) + + Defaults to 1209600 (2 weeks) + ## OCR settings {#ocr} Paperless uses [OCRmyPDF](https://ocrmypdf.readthedocs.io/en/latest/) diff --git a/src/paperless/settings.py b/src/paperless/settings.py index ebe64ba9e..9a57719a2 100644 --- a/src/paperless/settings.py +++ b/src/paperless/settings.py @@ -472,7 +472,10 @@ ACCOUNT_EMAIL_VERIFICATION = os.getenv( "optional", ) -ACCOUNT_SESSION_REMEMBER = __get_boolean("PAPERLESS_ACCOUNT_SESSION_REMEMBER") +ACCOUNT_SESSION_REMEMBER = __get_boolean("PAPERLESS_ACCOUNT_SESSION_REMEMBER", "True") +SESSION_COOKIE_AGE = int( + os.getenv("PAPERLESS_SESSION_COOKIE_AGE", 60 * 60 * 24 * 7 * 3), +) if AUTO_LOGIN_USERNAME: _index = MIDDLEWARE.index("django.contrib.auth.middleware.AuthenticationMiddleware")