-
Notifications
You must be signed in to change notification settings - Fork 14
/
config.py
199 lines (149 loc) · 6.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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
import json
import os
import jinja2
import dmcontent.govuk_frontend
from dmutils.status import get_version_label
from dmutils.asset_fingerprint import AssetFingerprinter
basedir = os.path.abspath(os.path.dirname(__file__))
class Config(object):
VERSION = get_version_label(
os.path.abspath(os.path.dirname(__file__))
)
SESSION_COOKIE_NAME = 'dm_session'
SESSION_COOKIE_PATH = '/'
SESSION_COOKIE_HTTPONLY = True
SESSION_COOKIE_SECURE = True
SESSION_COOKIE_SAMESITE = "Lax"
PERMANENT_SESSION_LIFETIME = 3600 # 1 hour
DM_COOKIE_PROBE_EXPECT_PRESENT = True
WTF_CSRF_ENABLED = True
WTF_CSRF_TIME_LIMIT = None
DM_DATA_API_URL = None
DM_DATA_API_AUTH_TOKEN = None
DM_SEARCH_API_URL = None
DM_SEARCH_API_AUTH_TOKEN = None
DM_MANDRILL_API_KEY = None
DM_REDIS_SERVICE_NAME = None
# Used for generating absolute URLs from relative URLs when necessary
DM_PATCH_FRONTEND_URL = 'http://localhost/'
# matches api(s)
DM_SEARCH_PAGE_SIZE = 100
# This is just a placeholder
ES_ENABLED = True
DEBUG = False
RESET_PASSWORD_EMAIL_NAME = 'Digital Marketplace Admin'
RESET_PASSWORD_EMAIL_FROM = '[email protected]'
RESET_PASSWORD_EMAIL_SUBJECT = 'Reset your Digital Marketplace password'
CREATE_USER_SUBJECT = 'Create your Digital Marketplace account'
SECRET_KEY = None
SHARED_EMAIL_KEY = None
RESET_PASSWORD_SALT = 'ResetPasswordSalt'
INVITE_EMAIL_SALT = 'InviteEmailSalt'
ASSET_PATH = '/static/'
BASE_TEMPLATE_DATA = {
'header_class': 'with-proposition',
'asset_path': ASSET_PATH,
'asset_fingerprinter': AssetFingerprinter(asset_root=ASSET_PATH)
}
# LOGGING
DM_LOG_LEVEL = 'DEBUG'
DM_PLAIN_TEXT_LOGS = False
DM_LOG_PATH = None
DM_APP_NAME = 'buyer-frontend'
#: For some frameworks (represented by the keys in this map), we store no framework content. But
#: they work just like some other framework (represented by the values in the map) for which we do
#: have content available. The map uses slugs to identify the framework pairs, so that we can still
#: find the framework data we need (and so that we can avoid trying to load up framework data that
#: isn't actually available).
DM_FRAMEWORK_CONTENT_MAP = {
'g-cloud-4': 'g-cloud-6',
'g-cloud-5': 'g-cloud-6',
}
DM_FEEDBACK_FORM = {
'uri': 'https://docs.google.com/a/digital.cabinet-office.gov.uk/forms/d/e/1FAIpQLSc-uXv-4VqGBipDwPhJFDpET5UrHnJpsJ5FFTn4-MBAfKeOPg/formResponse', # noqa
'fields': {
'uri': 'entry.1048271701',
'what_doing': 'entry.1348335665',
'what_happened': 'entry.869819225',
}
}
GOOGLE_SITE_VERIFICATION = None
@staticmethod
def init_app(app):
repo_root = os.path.abspath(os.path.dirname(__file__))
digitalmarketplace_govuk_frontend = os.path.join(repo_root, "node_modules", "digitalmarketplace-govuk-frontend")
govuk_frontend = os.path.join(repo_root, "node_modules", "govuk-frontend")
template_folders = [
os.path.join(repo_root, "app", "templates"),
os.path.join(govuk_frontend),
os.path.join(digitalmarketplace_govuk_frontend),
os.path.join(digitalmarketplace_govuk_frontend, "digitalmarketplace", "templates"),
]
jinja_loader = jinja2.FileSystemLoader(template_folders)
app.jinja_loader = jinja_loader
# Set the govuk_frontend_version to account for version-based quirks (eg: v3 Error Summary links to radios)
with open(os.path.join(repo_root, "node_modules", "govuk-frontend", "package.json")) as package_json_file:
package_json = json.load(package_json_file)
dmcontent.govuk_frontend.govuk_frontend_version = list(map(int, package_json["version"].split(".")))
class Test(Config):
DEBUG = True
DM_PLAIN_TEXT_LOGS = True
DM_LOG_LEVEL = 'CRITICAL'
WTF_CSRF_ENABLED = False
DM_DATA_API_URL = "http://wrong.completely.invalid:5000"
DM_DATA_API_AUTH_TOKEN = "myToken"
DM_SEARCH_API_URL = "http://wrong.completely.invalid:5009"
DM_SEARCH_API_AUTH_TOKEN = "myToken"
DM_MANDRILL_API_KEY = 'MANDRILL'
SHARED_EMAIL_KEY = "KEY"
SECRET_KEY = "KEY"
GOOGLE_SITE_VERIFICATION = "NotARealVerificationKey"
class Development(Config):
DEBUG = True
DM_PLAIN_TEXT_LOGS = True
SESSION_COOKIE_SECURE = False
DM_SEARCH_PAGE_SIZE = 5
DM_DATA_API_URL = f"http://localhost:{os.getenv('DM_API_PORT', 5000)}"
DM_DATA_API_AUTH_TOKEN = "myToken"
DM_SEARCH_API_URL = f"http://localhost:{os.getenv('DM_SEARCH_API_PORT', 5009)}"
DM_SEARCH_API_AUTH_TOKEN = "myToken"
DM_MANDRILL_API_KEY = "not_a_real_key"
SECRET_KEY = "verySecretKey"
SHARED_EMAIL_KEY = "very_secret"
GOOGLE_SITE_VERIFICATION = "NotARealVerificationKey"
class SharedLive(Config):
"""Base config for deployed environments shared between GPaaS and AWS"""
DEBUG = False
DM_HTTP_PROTO = 'https'
# use of invalid email addresses with live api keys annoys Notify
DM_NOTIFY_REDIRECT_DOMAINS_TO_ADDRESS = {
"example.com": "[email protected]",
"example.gov.uk": "[email protected]",
"user.marketplace.team": "[email protected]",
}
class NativeAWS(SharedLive):
DM_APP_NAME = 'buyer-frontend'
# DM_LOGIN_URL will be read from env vars - used to avoid incorrect host/port
# redirect from Flask-Login package
DM_LOGIN_URL = None
# SESSION_COOKIE_DOMAIN will be read from env vars - set to subdomain to
# allow session share between "www.' and "admin."
SESSION_COOKIE_DOMAIN = None
class Live(SharedLive):
"""Base config for deployed environments"""
DM_LOG_PATH = '/var/log/digitalmarketplace/application.log'
class Preview(Live):
DM_PATCH_FRONTEND_URL = 'https://www.preview.marketplace.team/'
class Staging(Live):
DM_PATCH_FRONTEND_URL = 'https://www.staging.marketplace.team/'
class Production(Live):
DM_PATCH_FRONTEND_URL = 'https://www.digitalmarketplace.service.gov.uk/'
GOOGLE_SITE_VERIFICATION = "TKGSGZnfHpx1-lKOthI17ANtwk7fz3F4Sbr77I0ppO0"
configs = {
'development': Development,
'native-aws': NativeAWS,
'test': Test,
'preview': Preview,
'staging': Staging,
'production': Production,
}