Skip to content

Commit 51acaa1

Browse files
committed
Generate the session signing key
1 parent 81a37a4 commit 51acaa1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

mrmat_python_api_flask/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import sys
2727
import os
2828
import logging
29+
import secrets
2930
import importlib.metadata
3031

3132
from rich.console import Console
@@ -75,8 +76,6 @@ def create_app(config_override=None, instance_path=None):
7576
#
7677
# Set configuration defaults. If a config file is present then load it. If we have overrides, apply them
7778

78-
# TODO
79-
#app.config.setdefault('SECRET_KEY', 'JFg4K1l5vVmusHmI0cNAFg')
8079
app.config.setdefault('SQLALCHEMY_DATABASE_URI',
8180
'sqlite+pysqlite:///' + os.path.join(app.instance_path, 'mrmat-python-api-flask.sqlite'))
8281
app.config.setdefault('SQLALCHEMY_TRACK_MODIFICATIONS', False)
@@ -86,6 +85,8 @@ def create_app(config_override=None, instance_path=None):
8685
app.config.from_json(os.path.expanduser(os.environ['FLASK_CONFIG']))
8786
if config_override is not None:
8887
app.config.from_mapping(config_override)
88+
if app.config['SECRET_KEY'] is None:
89+
app.config['SECRET_KEY'] = secrets.token_urlsafe(16)
8990

9091
#
9192
# Create the instance folder if it does not exist

0 commit comments

Comments
 (0)