Skip to content

Commit cccf5cb

Browse files
committed
#870: update Flask's SECRET_KEY to be a random string
1 parent 81578f4 commit cccf5cb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

dtale/app.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import jinja2
55
import logging
66
import os
7+
import numpy as np
78
import pandas as pd
89
import random
910
import socket
11+
import string
1012
import sys
1113
import time
1214
import traceback
@@ -292,6 +294,14 @@ def get_send_file_max_age(self, name):
292294
return super(DtaleFlask, self).get_send_file_max_age(name)
293295

294296

297+
def build_secret_key():
298+
"""
299+
Builds a string of 10 randomly chosen characters to be used as the Flask app's SECRET_KEY
300+
"""
301+
302+
return "".join(np.random.choice(list(string.ascii_uppercase + string.digits), 10))
303+
304+
295305
def build_app(
296306
url=None, reaper_on=True, app_root=None, additional_templates=None, **kwargs
297307
):
@@ -320,7 +330,7 @@ def build_app(
320330
instance_relative_config=False,
321331
app_root=app_root,
322332
)
323-
app.config["SECRET_KEY"] = "Dtale"
333+
app.config["SECRET_KEY"] = build_secret_key()
324334

325335
app.jinja_env.trim_blocks = True
326336
app.jinja_env.lstrip_blocks = True

0 commit comments

Comments
 (0)