-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
113 lines (94 loc) · 4.27 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
# A web application that stores samples from a collection of NFC sensors.
#
# https://github.com/cuplsensor/cuplbackend
#
# Original Author: Malcolm Mackay
# Email: malcolm@plotsensor.com
# Website: https://cupl.co.uk
#
# Copyright (c) 2021. Plotsensor Ltd.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation, either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the
# GNU Affero General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>.
# A web application that stores samples from a collection of NFC sensors.
#
# https://github.com/cuplsensor/cuplbackend
#
# Original Author: Malcolm Mackay
# Email: malcolm@plotsensor.com
# Website: https://cupl.co.uk
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License
# as published by the Free Software Foundation, either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the
# GNU Affero General Public License along with this program.
# If not, see <https://www.gnu.org/licenses/>.
from base64 import b64decode
from . import defaults
# Define the application directory
import os
BASE_DIR = 'home/debian/'
# Define the database - we are working with
# SQLite for this example
DB_NAME = os.environ['DB_NAME']
DB_USER = os.environ['DB_USER']
DB_PASS = os.environ['DB_PASS']
DB_HOST = os.environ['DB_HOST']
DB_PORT = os.environ['DB_PORT']
SQLALCHEMY_DATABASE_URI = 'postgresql://{0}:{1}@{2}:{3}/{4}'.format(
DB_USER, DB_PASS, DB_HOST, DB_PORT, DB_NAME
)
DATABASE_CONNECT_OPTIONS = {}
SQLALCHEMY_TRACK_MODIFICATIONS = False
# Application threads. A common general assumption is
# using 2 per available processor cores - to handle
# incoming requests using one and performing background
# operations using the other.
THREADS_PER_PAGE = 2
# Enable protection agains *Cross-site Request Forgery (CSRF)*
CSRF_ENABLED = True
# Use a secure, unique and absolutely secret key for
# signing the data.
CSRF_SESSION_KEY = os.environ['CSRF_SESSION_KEY']
# Secret key for signing cookies
SECRET_KEY = os.environ['SECRET_KEY']
# HashIds Salt
HASHIDS_SALT = os.environ['HASHIDS_SALT']
HASHIDS_OFFSET = int(os.getenv('HASHIDS_OFFSET', defaults.HASHIDS_OFFSET))
DROP_ON_INIT = (os.getenv('DROP_ON_INIT', defaults.DROP_ON_INIT).lower() == 'true') # Flag to drop tables on startup.
TAGTOKEN_CLIENTID = os.getenv('TAGTOKEN_CLIENTID', defaults.TAGTOKEN_CLIENTID)
TAGTOKEN_CLIENTSECRET = os.environ['TAGTOKEN_CLIENTSECRET']
ADMINAPI_AUDIENCE = os.getenv('ADMINAPI_AUDIENCE', defaults.ADMINAPI_AUDIENCE)
ADMINAPI_CLIENTID = os.getenv('ADMINAPI_CLIENTID', defaults.ADMINAPI_CLIENTID)
ADMINAPI_CLIENTSERET = os.environ['ADMINAPI_CLIENTSECRET']
RATELIMIT_DEFAULT = os.environ.get('RATELIMIT_DEFAULT', defaults.RATELIMIT_DEFAULT)
RATELIMIT_HEADERS_ENABLED = (os.getenv('RATELIMIT_HEADERS_ENABLED', defaults.RATELIMIT_HEADERS_ENABLED).lower() == 'true')
RATELIMIT_ENABLED = (os.getenv('RATELIMIT_ENABLED', defaults.RATELIMIT_ENABLED).lower() == 'true')
RATELIMIT_STORAGE_URL = os.getenv('RATELIMIT_STORAGE_URL', defaults.RATELIMIT_STORAGE_URL)
RATELIMIT_STRATEGY = os.getenv('RATELIMIT_STRATEGY', defaults.RATELIMIT_STRATEGY)
WSB_PORT = os.getenv('WSB_PORT', defaults.WSB_PORT)
WSB_HOST = os.getenv('WSB_HOST', defaults.WSB_HOST)
WSB_PROTOCOL = os.getenv('WSB_PROTOCOL', defaults.WSB_PROTOCOL)
SERVER_NAME = os.getenv('SERVER_NAME', None) #os.getenv('SERVER_NAME', "{host}:{port}".format(host=WSB_HOST, port=WSB_PORT))
CORS_EXPOSE_HEADERS = ["Link", "X-CuplBackend-Hmac-SHA256"]
PREFERRED_URL_SCHEME = WSB_PORT.replace("://", "")