Skip to content

Commit

Permalink
Added COOKIE_EXPIRATION environment variable (#4801)
Browse files Browse the repository at this point in the history
Added COOKIE_EXPIRATION environment variable

Co-authored-by: Katherine Fleming <[email protected]>
  • Loading branch information
axelstudios and kflemin authored Sep 18, 2024
1 parent f3d5fb5 commit 33d1691
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
10 changes: 2 additions & 8 deletions config/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@

PROTOCOL = os.environ.get("PROTOCOL", "https")

SESSION_COOKIE_DOMAIN = None
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
DATA_UPLOAD_MAX_MEMORY_SIZE = None

# TODO: remove managers, admins in config files.
ADMINS = (
# ('Your Name', '[email protected]'),
)
MANAGERS = ADMINS

# See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application
WSGI_APPLICATION = "config.wsgi.application"

Expand All @@ -43,6 +35,8 @@
SECRET_KEY = os.environ.get("SECRET_KEY", "default-ns=nb-w)#2ue-mtu!s&2krzfee1-t)^z7y8gyrp6mx^d*weifh")

SESSION_ENGINE = "django.contrib.sessions.backends.signed_cookies"
# Default to expiring cookies after 2 weeks
SESSION_COOKIE_AGE = int(os.environ.get("COOKIE_EXPIRATION", 1_209_600))

TEMPLATES = [
{
Expand Down
4 changes: 3 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ SEED_ADMIN_PASSWORD (required), admin password for SEED
SEED_ADMIN_ORG (required), default organization for admin user in SEED
SECRET_KEY (required), unique key for SEED web application
AWS_ACCESS_KEY_ID (optional), Access key for AWS
AWS_SECRET_ACCESS_KEY, Secret key for AWS
AWS_SECRET_ACCESS_KEY (optional), Secret key for AWS
AWS_SES_REGION_NAME (optional), AWS Region for SES
AWS_SES_REGION_ENDPOINT (optional), AWS endpoint for SES
COOKIE_EXPIRATION (optional), Time in seconds that a session should be valid
SERVER_EMAIL (optional), Email that is used by the server to send messages
SENTRY_JS_DSN (optional), Sentry JavaScript DSN
SENTRY_RAVEN_DSN (optional), Sentry Django DSN (Raven-based)
Expand All @@ -42,6 +43,7 @@ export AWS_ACCESS_KEY_ID=key
export AWS_SECRET_ACCESS_KEY=secret_key
export AWS_SES_REGION_NAME=us-west-2
export AWS_SES_REGION_ENDPOINT=email.us-west-2.amazonaws.com
export COOKIE_EXPIRATION=1209600
export [email protected]
export SENTRY_JS_DSN=https://[email protected]/123456789
export SENTRY_RAVEN_DSN=https://abcd:[email protected]/123456789
Expand Down
1 change: 1 addition & 0 deletions docker-compose.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ services:
- SEED_ADMIN_PASSWORD
- SEED_ADMIN_ORG
- SECRET_KEY
- COOKIE_EXPIRATION
# Pass the Sentry config to the containers
- SENTRY_RAVEN_DSN
- SENTRY_JS_DSN
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ services:
- SEED_ADMIN_PASSWORD=super-secret-password
- SEED_ADMIN_ORG=default
- SECRET_KEY=ARQV8qGuJKH8sGnBf6ZeEdJQRKLTUhsvEcp8qG9X9sCPXvGLhdxqnNXpZcy6HEyf
- COOKIE_EXPIRATION
- DJANGO_SETTINGS_MODULE=config.settings.docker
- NGINX_LISTEN_OPTS="http2"
# Sentry configuration if you want to use it (make sure to enable on web-celery container too)
Expand Down
3 changes: 3 additions & 0 deletions docs/source/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ Ubuntu server 18.04 or newer with a m5ad.xlarge (if using in Production instance
export AWS_SES_REGION_ENDPOINT=email.us-west-2.amazonaws.com
export [email protected]
# For custom cookie validity duration
export COOKIE_EXPIRATION=1209600
* Before launching the first time, make sure the persistent volumes and the backup directory exist.

Expand Down
2 changes: 2 additions & 0 deletions docs/source/kubernetes_deployment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ This chart contains the deployment specification for the SEED web container. Re
value: <super-secret-password>
- name: SEED_ADMIN_USER
value: <[email protected]>
- name: COOKIE_EXPIRATION
value: 1209600
# Postgres variables
- name: POSTGRES_DB
value: seed
Expand Down

0 comments on commit 33d1691

Please sign in to comment.