-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
141 lines (97 loc) · 4.05 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import os
from datetime import timedelta
# todo clean config
class Config(object):
DEBUG = False
TESTING = False
DEVELOPMENT = False
LOGIN_DISABLED = False
API_PAGINATION = 10
PROPAGATE_EXCEPTIONS = True # needed due to Flask-Restful not passing them up
SQLALCHEMY_TRACK_MODIFICATIONS = False # ref: https://stackoverflow.com/questions/33738467/how-do-i-know-if-i-can-disable-sqlalchemy-track-modifications/33790196#33790196
CSRF_COOKIE_SECURE = True
CSRF_COOKIE_NAME = "X-CSRF-TOKEN"
REMEMBER_COOKIE_DURATION = timedelta(days=15)
REMEMBER_COOKIE_SECURE = True
REMEMBER_COOKIE_HTTPONLY = True
BACKEND_SERVER_PORT = "4999"
BACKEND_SERVER_HOST = "127.0.0.1"
BACKEND_SERVER_URL = "https://%s:%s" % (BACKEND_SERVER_HOST, BACKEND_SERVER_PORT)
SECRET_KEY = os.getenv("SECRET")
INVITES_SECRET = SECRET_KEY
PASSWORD_RESET_SECRET = SECRET_KEY
PUBLIC_VALIDATION_SECRET = SECRET_KEY
RECAPTCHA = os.getenv("RECAPTCHA")
RECAPTCHA_URL = "https://www.google.com/recaptcha/api/siteverify"
SMTP_PASSWORD = os.getenv("SMTP_PASSWORD")
SMTP_DOMAIN = os.getenv("SMTP_DOMAIN")
SMTP_USER = os.getenv("SMTP_USER")
SMTP_FROM_EMAIL = SMTP_USER # email which will be shown in the 'from' field
SMTP_REPLY_TO = SMTP_FROM_EMAIL
SMTP_TLS_PORT = 465
SMTP_BULK_PASSWORD = os.getenv("SMTP_BULK_PASSWORD")
SMTP_BULK_USER = os.getenv("SMTP_BULK_USER")
SMTP_BULK_DOMAIN = os.getenv("SMTP_BULK_DOMAIN")
SMTP_BULK_FROM_EMAIL = SMTP_USER # email which will be shown in the 'from' field
SMTP_BULK_REPLY_TO = SMTP_REPLY_TO
SMTP_BULK_PORT = 587
TOTP_ENCRYPTION_KEY = os.getenv("TOTP_ENCRYPTION")
BCC_ADMIN = False
DEBUGGING_EMAIL = "[email protected]"
DEBUGGING_MODE = bool(int(os.getenv("EMAIL_DEBUGGING_MODE", 0)))
DEBUGGING_SEND_EMAILS = True
DISCORD_LOGIN_NOTIFICATIONS = os.getenv("DISCORD_LOGIN_NOTIFICATIONS")
DISCORD_LOGIN_NOTIFICATIONS_ALERT = os.getenv("DISCORD_LOGIN_NOTIFICATIONS_ALERT")
class DevelopmentConfig(Config):
DEBUG = True
DEVELOPMENT = True
SQLALCHEMY_ECHO = False
CSRF_DISABLE = True
LOGIN_DISABLED = True
TESTING = True
SSL_CERT = "development/cert.pem"
SSL_KEY = "development/key.pem"
CSRF_COOKIE_SAMESITE = "Lax" # allow development frontend server
FRONTEND_SERVER_URL = "https://127.0.0.1:3000"
SQLALCHEMY_DATABASE_URI = "sqlite:///%s" % os.path.join(
os.path.abspath(os.path.dirname(__file__)), "", "people.db"
)
class DevelopmentBuiltConfig(DevelopmentConfig):
CSRF_COOKIE_SAMESITE = "Strict"
SESSION_PROTECTION = "basic" # not strict to allow the remember me
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SAMESITE = "Strict"
CSRF_DISABLE = False
LOGIN_DISABLED = False
DEVELOPMENT = False
LOGIN_DISABLED = False
FRONTEND_SERVER_URL = "https://127.0.0.1:4999"
SQLALCHEMY_DATABASE_URI = "sqlite:///%s" % os.path.join(
os.path.abspath(os.path.dirname(__file__)), "", "people.db"
)
class ProductionConfig(Config):
CSRF_COOKIE_SAMESITE = "Lax"
SESSION_PROTECTION = "strong"
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SAMESITE = "Strict"
BACKEND_SERVER_PORT = "443"
BACKEND_SERVER_HOST = "c4.xamfra.net"
BACKEND_SERVER_URL = "https://%s:%s" % (BACKEND_SERVER_HOST, BACKEND_SERVER_PORT)
FRONTEND_SERVER_URL = BACKEND_SERVER_URL
SQLALCHEMY_DATABASE_URI = os.getenv("DATABASE_URL")
class HerokuManualLiveConfig(ProductionConfig):
SECRET_KEY = "super-secret"
INVITES_SECRET = "super-secret"
PASSWORD_RESET_SECRET = "super-secret"
PUBLIC_VALIDATION_SECRET = "super-secret"
FRONTEND_SERVER_URL = "https://c4.xamfra.net"
BACKEND_SERVER_PORT = "443"
BACKEND_SERVER_HOST = "c4.xamfra.net"
SQLALCHEMY_DATABASE_URI = os.getenv("MANUAL_DATABASE_URL")
class TestingConfig(DevelopmentConfig):
TESTING = True
class TestingConfigNoDb(DevelopmentConfig):
TESTING = True
SQLALCHEMY_DATABASE_URI = None