-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.py
74 lines (57 loc) · 2.32 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
Global Configuration
"""
import os
from app import app
from flask_jwt_extended import JWTManager
### DATABASE CONFIGURATION ###
# Use below config to use with POSTGRES:
# check for env variable (postgres), if not found use local sqlite database
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get(
"DATABASE_URL_SQLALCHEMY", "sqlite:///data.db"
)
app.config[
"SQLALCHEMY_TRACK_MODIFICATIONS"
] = False # flask-sqlalchemy tracker is off, sqlalchemy has its own tracker
app.config[
"PROPAGATE_EXCEPTIONS"
] = True # to allow flask propagating exception even if debug is set to false
### JWT CONFIGURATION ###
app.config["JWT_SECRET_KEY"] = os.urandom(24)
app.config["JWT_BLACKLIST_ENABLED"] = True # enable blacklist feature
app.config["JWT_BLACKLIST_TOKEN_CHECKS"] = [
"access",
"refresh",
] # allow blacklisting for access and refresh tokens
jwt = JWTManager(app)
### SESSION CONFIGURATION ###
app.secret_key = os.urandom(24) # need this for session management
# (flask-session-change) Enable below to keep session data with SQLAlchemy:
# sessions work ok locally but may not be persistent with Heroku free tier.
# from flask_session import Session
# from flask import session
# app.config["SESSION_TYPE"] = "sqlalchemy"
# app.config["SESSION_SQLALCHEMY"] = db # SQLAlchemy object
# app.config["SESSION_SQLALCHEMY_TABLE"] = "session" # session table name
# app.config["SESSION_PERMANENT"] = True
# app.config["SESSION_USE_SIGNER"] = False # browser session cookie value to encrypt
# app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(minutes=30)
# app.config[
# "SESSION_KEY_PREFIX"
# ] = "session:" # the prefix of the value stored in session
# (flask-session-change) Enable below to keep session data in the file system:
# app.config["SESSION_TYPE"] = "filesystem"
# app.config["SESSION_PERMANENT"] = True
# app.config["SESSION_USE_SIGNER"] = False # browser session cookie value to encrypt
# app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(minutes=30)
# app.config[
# "SESSION_KEY_PREFIX"
# ] = "session:" # the prefix of the value stored in session
# # Enable if using sessions with SQLAlchemy to create table to store session data:
# #
# Fsession = Session(app)
#
# with app.app_context():
# if app.config["SESSION_TYPE"] == "sqlalchemy":
# Fsession.app.session_interface.db.create_all()
# #