Fall back to random secret key on permission exception

Fixes #1136
main
Ben Busby 4 weeks ago
parent 80e41e6b44
commit 37ff61dfac
No known key found for this signature in database
GPG Key ID: B9B7231E01D924A1

@ -101,7 +101,10 @@ if not os.path.exists(app.config['BUILD_FOLDER']):
# Session values # Session values
app_key_path = os.path.join(app.config['CONFIG_PATH'], 'whoogle.key') app_key_path = os.path.join(app.config['CONFIG_PATH'], 'whoogle.key')
if os.path.exists(app_key_path): if os.path.exists(app_key_path):
app.config['SECRET_KEY'] = open(app_key_path, 'r').read() try:
app.config['SECRET_KEY'] = open(app_key_path, 'r').read()
except PermissionError:
app.config['SECRET_KEY'] = str(b64encode(os.urandom(32)))
else: else:
app.config['SECRET_KEY'] = str(b64encode(os.urandom(32))) app.config['SECRET_KEY'] = str(b64encode(os.urandom(32)))
with open(app_key_path, 'w') as key_file: with open(app_key_path, 'w') as key_file:

Loading…
Cancel
Save