Skip to content

Commit 2711a0c

Browse files
committed
set cookie attributes for security
1 parent 7d03026 commit 2711a0c

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

app/app.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import os
88

99
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY')
10+
app.config['SESSION_COOKIE_HTTPONLY'] = True
11+
app.config['SESSION_COOKIE_SECURE'] = bool(os.getenv('SESSION_COOKIE_SECURE'))
12+
1013
csrf = CSRFProtect(app)
1114

1215
@app.route('/', methods=['GET', 'POST'])

compose.dev.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ services:
1111
environment:
1212
FLASK_APP: app.py
1313
SECRET_KEY: supersecret
14+
SESSION_COOKIE_SECURE: 0
1415
OPENAI_API_KEY: ${OPENAI_API_KEY} # Set your OpenAI API key here or in the .env file
1516
command: flask run --host=0.0.0.0
1617
deploy:

compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ services:
1414
environment:
1515
FLASK_APP: app.py
1616
SECRET_KEY:
17+
SESSION_COOKIE_SECURE: 1
1718
OPENAI_API_KEY: ${OPENAI_API_KEY} # Set your OpenAI API key here or in the .env file
1819
command: uwsgi --http 0.0.0.0:5000 --wsgi-file app.py --callable app --processes 4 --threads 2
1920
deploy:

0 commit comments

Comments
 (0)