Skip to content

Commit 6e5d005

Browse files
sampaccoudlunika
authored andcommitted
✨(backend) allow setting session cookie age via env var
We want to be able to increase the duration of the cookie session by setting an environment variable.
1 parent 6377c8f commit 6e5d005

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ and this project adheres to
1010

1111
## Added
1212

13-
- ✨(back) allow theme customnization using a configuration file #948
13+
- ✨(backend) allow setting session cookie age via env var #977
14+
- ✨(backend) allow theme customnization using a configuration file #948
1415
- ✨ Add a custom callout block to the editor #892
1516
- 🚩(frontend) version MIT only #911
1617
- ✨(backend) integrate maleware_detection from django-lasuite #936

docs/env.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ These are the environment variables you can set for the `impress-backend` contai
3939
| DJANGO_EMAIL_PORT | port used to connect to email host | |
4040
| DJANGO_EMAIL_USE_TLS | use tls for email host connection | false |
4141
| DJANGO_EMAIL_USE_SSL | use sstl for email host connection | false |
42-
| DJANGO_EMAIL_FROM | email address used as sender | from@example.com |
42+
| DJANGO_EMAIL_FROM | email address used as sender | from@example.com |
4343
| DJANGO_CORS_ALLOW_ALL_ORIGINS | allow all CORS origins | true |
4444
| DJANGO_CORS_ALLOWED_ORIGINS | list of origins allowed for CORS | [] |
4545
| DJANGO_CORS_ALLOWED_ORIGIN_REGEXES | list of origins allowed for CORS using regulair expressions | [] |
@@ -54,12 +54,13 @@ These are the environment variables you can set for the `impress-backend` contai
5454
| CRISP_WEBSITE_ID | crisp website id for support | |
5555
| DJANGO_CELERY_BROKER_URL | celery broker url | redis://redis:6379/0 |
5656
| DJANGO_CELERY_BROKER_TRANSPORT_OPTIONS | celery broker transport options | {} |
57+
| SESSION_COOKIE_AGE | duration of the cookie session | 60*60*12 |
5758
| OIDC_CREATE_USER | create used on OIDC | false |
5859
| OIDC_RP_SIGN_ALGO | verification algorithm used OIDC tokens | RS256 |
5960
| OIDC_RP_CLIENT_ID | client id used for OIDC | impress |
6061
| OIDC_RP_CLIENT_SECRET | client secret used for OIDC | |
6162
| OIDC_OP_JWKS_ENDPOINT | JWKS endpoint for OIDC | |
62-
| OIDC_OP_AUTHORIZATION_ENDPOINT | Authorization endpoint for OIDC | |
63+
| OIDC_OP_AUTHORIZATION_ENDPOINT | Authorization endpoint for OIDC | |
6364
| OIDC_OP_TOKEN_ENDPOINT | Token endpoint for OIDC | |
6465
| OIDC_OP_USER_ENDPOINT | User endpoint for OIDC | |
6566
| OIDC_OP_LOGOUT_ENDPOINT | Logout endpoint for OIDC | |
@@ -73,7 +74,7 @@ These are the environment variables you can set for the `impress-backend` contai
7374
| OIDC_REDIRECT_ALLOWED_HOSTS | Allowed hosts for OIDC redirect url | [] |
7475
| OIDC_STORE_ID_TOKEN | Store OIDC token | true |
7576
| OIDC_FALLBACK_TO_EMAIL_FOR_IDENTIFICATION | faillback to email for identification | true |
76-
| OIDC_ALLOW_DUPLICATE_EMAILS | Allow duplicate emails | false |
77+
| OIDC_ALLOW_DUPLICATE_EMAILS | Allow duplicate emails | false |
7778
| USER_OIDC_ESSENTIAL_CLAIMS | essential claims in OIDC token | [] |
7879
| OIDC_USERINFO_FULLNAME_FIELDS | OIDC token claims to create full name | ["first_name", "last_name"] |
7980
| OIDC_USERINFO_SHORTNAME_FIELD | OIDC token claims to create shortname | first_name |

src/backend/impress/settings.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,9 @@ class Base(Configuration):
462462
# Session
463463
SESSION_ENGINE = "django.contrib.sessions.backends.cache"
464464
SESSION_CACHE_ALIAS = "default"
465-
SESSION_COOKIE_AGE = 60 * 60 * 12
465+
SESSION_COOKIE_AGE = values.PositiveIntegerValue(
466+
default=60 * 60 * 12, environ_name="SESSION_COOKIE_AGE", environ_prefix=None
467+
)
466468

467469
# OIDC - Authorization Code Flow
468470
OIDC_CREATE_USER = values.BooleanValue(

0 commit comments

Comments
 (0)