Browse Source

random generation of secrets

main
cellarspoon 3 years ago
parent
commit
394e128e9f
No known key found for this signature in database GPG Key ID: 3789458B3D0C410
  1. 12
      app.py

12
app.py

@ -1,4 +1,6 @@
import os import os
import random
import string
from pathlib import Path from pathlib import Path
import petname import petname
@ -11,9 +13,15 @@ from werkzeug.utils import secure_filename
from wtforms import HiddenField, RadioField, StringField from wtforms import HiddenField, RadioField, StringField
from wtforms.validators import DataRequired from wtforms.validators import DataRequired
def rand():
"""Generated random secret."""
return "".join(random.choices(string.ascii_uppercase + string.digits, k=N))
app = Flask(__name__) app = Flask(__name__)
app.config["SECRET_KEY"] = "foo" app.config["SECRET_KEY"] = os.environ.get("SECRET_KEY", rand())
app.config["WTF_CSRF_SECRET_KEY"] = "bar" app.config["WTF_CSRF_SECRET_KEY"] = os.environ.get("WTF_CSRF_SECRET_KEY", rand())
CWD = Path().resolve() CWD = Path().resolve()

Loading…
Cancel
Save