-
Notifications
You must be signed in to change notification settings - Fork 3
/
layman_settings.py
227 lines (181 loc) · 7.88 KB
/
layman_settings.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
import os
import re
from urllib.parse import urljoin, urlparse
import redis
import db
import geoserver
from layman_settings_util import read_clients_dict_from_env
LAYMAN_DATA_DIR = os.environ['LAYMAN_DATA_DIR']
FILE_TYPE_VECTOR = 'vector'
FILE_TYPE_RASTER = 'raster'
MAIN_FILE_EXTENSIONS = {
'.geojson': FILE_TYPE_VECTOR,
'.shp': FILE_TYPE_VECTOR,
'.tiff': FILE_TYPE_RASTER,
'.tif': FILE_TYPE_RASTER,
'.jp2': FILE_TYPE_RASTER,
'.png': FILE_TYPE_RASTER,
'.jpg': FILE_TYPE_RASTER,
}
INPUT_SRS_LIST = [
'EPSG:3857',
'EPSG:4326',
]
DEFAULT_CONNECTION_TIMEOUT = int(os.environ['DEFAULT_CONNECTION_TIMEOUT'])
LAYMAN_PG_HOST = os.environ['LAYMAN_PG_HOST']
LAYMAN_PG_PORT = os.environ['LAYMAN_PG_PORT']
LAYMAN_PG_DBNAME = os.environ['LAYMAN_PG_DBNAME']
LAYMAN_PG_USER = os.environ['LAYMAN_PG_USER']
LAYMAN_PG_PASSWORD = os.environ['LAYMAN_PG_PASSWORD']
PG_CONN = {
'host': LAYMAN_PG_HOST,
'port': LAYMAN_PG_PORT,
'dbname': LAYMAN_PG_DBNAME,
'user': LAYMAN_PG_USER,
'password': LAYMAN_PG_PASSWORD,
}
db.PG_CONN = PG_CONN
GEOSERVER_ADMIN_USER = 'admin'
GEOSERVER_ADMIN_PASSWORD = os.getenv('GEOSERVER_ADMIN_PASSWORD', None)
GEOSERVER_ADMIN_AUTH = None if GEOSERVER_ADMIN_PASSWORD is None else (GEOSERVER_ADMIN_USER,
GEOSERVER_ADMIN_PASSWORD)
GEOSERVER_DATADIR = '/geoserver/data_dir'
GEOSERVER_INITIAL_DATADIR = '/geoserver/initial_data_dir'
LAYMAN_GS_ROLE_SERVICE = os.getenv('LAYMAN_GS_ROLE_SERVICE', '') or 'default'
LAYMAN_GS_USER_GROUP_SERVICE = os.getenv('LAYMAN_GS_USER_GROUP_SERVICE', '') or 'default'
LAYMAN_GS_USER = os.environ['LAYMAN_GS_USER']
LAYMAN_GS_PASSWORD = os.environ['LAYMAN_GS_PASSWORD']
LAYMAN_GS_AUTH = (LAYMAN_GS_USER, LAYMAN_GS_PASSWORD)
LAYMAN_GS_HOST = os.environ['LAYMAN_GS_HOST']
LAYMAN_GS_PORT = os.environ['LAYMAN_GS_PORT']
LAYMAN_GS_PATH = os.environ['LAYMAN_GS_PATH']
LAYMAN_GS_URL = f"http://{LAYMAN_GS_HOST}:{LAYMAN_GS_PORT}{LAYMAN_GS_PATH}"
geoserver.set_settings(LAYMAN_GS_URL, LAYMAN_GS_ROLE_SERVICE, LAYMAN_GS_USER_GROUP_SERVICE, DEFAULT_CONNECTION_TIMEOUT, )
geoserver.GS_AUTH = LAYMAN_GS_AUTH
LAYMAN_GS_ROLE = os.environ['LAYMAN_GS_ROLE']
LAYMAN_GS_AUTHN_HTTP_HEADER_NAME = 'laymanHttpHeader'
LAYMAN_GS_AUTHN_HTTP_HEADER_ATTRIBUTE = os.environ['LAYMAN_GS_AUTHN_HTTP_HEADER_ATTRIBUTE']
assert re.match("[a-z][a-z0-9]*", LAYMAN_GS_AUTHN_HTTP_HEADER_ATTRIBUTE), "Only lowercase characters and numbers " \
"should be used for " \
"LAYMAN_GS_AUTHN_HTTP_HEADER_ATTRIBUTE. "
LAYMAN_GS_AUTHN_FILTER_NAME = 'laymanHttpFilter_v2'
LAYMAN_GS_AUTHN_FILTER_NAME_OLD = ['laymanHttpFilter']
LAYMAN_GS_WMS_WORKSPACE_POSTFIX = '_wms'
LAYMAN_OUTPUT_SRS_LIST = [
int(code) for code in os.environ['LAYMAN_OUTPUT_SRS_LIST'].split(',')
if len(code) > 0
]
for mandatory_srs in [3857, 4326]:
if mandatory_srs not in LAYMAN_OUTPUT_SRS_LIST:
LAYMAN_OUTPUT_SRS_LIST.append(mandatory_srs)
LAYMAN_QGIS_HOST = os.environ['LAYMAN_QGIS_HOST']
LAYMAN_QGIS_PORT = os.environ['LAYMAN_QGIS_PORT']
LAYMAN_QGIS_PATH = os.environ['LAYMAN_QGIS_PATH']
LAYMAN_QGIS_URL = f"http://{LAYMAN_QGIS_HOST}:{LAYMAN_QGIS_PORT}{LAYMAN_QGIS_PATH}"
LAYMAN_QGIS_DATA_DIR = os.environ['LAYMAN_QGIS_DATA_DIR']
LAYMAN_NORMALIZED_RASTER_DATA_DIR_NAME = os.environ['LAYMAN_GS_NORMALIZED_RASTER_DIRECTORY']
LAYMAN_NORMALIZED_RASTER_DATA_DIR = os.path.join(GEOSERVER_DATADIR, LAYMAN_NORMALIZED_RASTER_DATA_DIR_NAME)
# Name of schema, where Layman stores data about publication, users, ...
LAYMAN_PRIME_SCHEMA = os.environ['LAYMAN_PRIME_SCHEMA']
assert re.match("[a-z_][a-z0-9_]*", LAYMAN_PRIME_SCHEMA), "Only lowercase characters, numbers and underscore " \
"should be used for " \
"PG_PRIME_SCHEMA. "
# List of schemas that are not allowed to be used as usernames.
PG_NON_USER_SCHEMAS = [
'public',
'topology',
'pg_catalog',
'pg_toast',
'information_schema',
LAYMAN_PRIME_SCHEMA,
]
PG_POSTGIS_SCHEMA = 'public'
# Name of "everyone" role in rights
RIGHTS_EVERYONE_ROLE = "EVERYONE"
ANONYM_USER = "--ANONYM--"
NONAME_USER = "--NONAME--"
# related to testing only
LAYMAN_PG_TEMPLATE_DBNAME = os.getenv('LAYMAN_PG_TEMPLATE_DBNAME')
LAYMAN_CELERY_QUEUE = os.environ['LAYMAN_CELERY_QUEUE']
PUBLICATION_MODULES = [
'layman.layer',
'layman.map',
]
LAYMAN_AUTHN_MODULES = [
m for m in os.getenv('LAYMAN_AUTHN_MODULES', '').split(',')
if len(m) > 0
]
if 'layman.authn.http_header' not in LAYMAN_AUTHN_MODULES:
LAYMAN_AUTHN_MODULES.append('layman.authn.http_header')
LAYMAN_AUTHN_HTTP_HEADER_NAME = os.environ['LAYMAN_AUTHN_HTTP_HEADER_NAME']
assert re.match("[a-z][a-z0-9]*", LAYMAN_AUTHN_HTTP_HEADER_NAME), "Only lowercase characters and numbers " \
"should be used for " \
"LAYMAN_AUTHN_HTTP_HEADER_NAME. "
LAYMAN_AUTHN_OAUTH2_PROVIDERS = [
m for m in os.getenv('LAYMAN_AUTHN_OAUTH2_PROVIDERS', '').split(',')
if len(m) > 0
]
LAYMAN_AUTHN_CACHE_MAX_TIMEOUT = 60
OAUTH2_LIFERAY_AUTH_URLS = [
u for u in [
os.getenv('OAUTH2_LIFERAY_AUTH_URL', ''),
]
if len(u) > 0
]
OAUTH2_LIFERAY_INTROSPECTION_URL = os.getenv('OAUTH2_LIFERAY_INTROSPECTION_URL', None)
OAUTH2_LIFERAY_USER_PROFILE_URL = os.getenv('OAUTH2_LIFERAY_USER_PROFILE_URL', None)
OAUTH2_LIFERAY_CLIENTS = [
d for d in read_clients_dict_from_env()
if len(d['id']) > 0
]
GRANT_CREATE_PUBLIC_WORKSPACE = {
name for name in os.environ['GRANT_CREATE_PUBLIC_WORKSPACE'].split(',')
if name
}
GRANT_PUBLISH_IN_PUBLIC_WORKSPACE = {
name for name in os.environ['GRANT_PUBLISH_IN_PUBLIC_WORKSPACE'].split(',')
if name
}
if RIGHTS_EVERYONE_ROLE not in GRANT_PUBLISH_IN_PUBLIC_WORKSPACE:
assert not GRANT_CREATE_PUBLIC_WORKSPACE.difference(GRANT_PUBLISH_IN_PUBLIC_WORKSPACE)
# UPLOAD_MAX_INACTIVITY_TIME = 10 # 10 seconds
UPLOAD_MAX_INACTIVITY_TIME = 5 * 60 # 5 minutes
# max time (in seconds) to cache GeoServer's requests like WMS capabilities
LAYMAN_CACHE_GS_TIMEOUT = 1 * 60 # 1 minute
LAYMAN_REDIS_URL = os.environ['LAYMAN_REDIS_URL']
LAYMAN_REDIS = redis.Redis.from_url(LAYMAN_REDIS_URL, encoding="utf-8", decode_responses=True)
LAYMAN_TIMGEN_URL = os.environ['LAYMAN_TIMGEN_URL']
LAYMAN_CLIENT_URL = os.environ['LAYMAN_CLIENT_URL']
LAYMAN_CLIENT_PUBLIC_URL = os.environ['LAYMAN_CLIENT_PUBLIC_URL']
LAYMAN_SERVER_NAME = os.environ['LAYMAN_SERVER_NAME']
LAYMAN_PROXY_SERVER_NAME = os.environ['LAYMAN_PROXY_SERVER_NAME']
LAYMAN_GS_PROXY_BASE_URL = os.getenv('LAYMAN_GS_PROXY_BASE_URL', urljoin(LAYMAN_CLIENT_PUBLIC_URL, LAYMAN_GS_PATH))
CSW_URL = os.getenv('CSW_URL', None)
CSW_PROXY_URL = os.getenv('CSW_PROXY_URL', None)
CSW_BASIC_AUTHN = None if ':' not in os.getenv('CSW_BASIC_AUTHN', '') else tuple(
os.environ['CSW_BASIC_AUTHN'].split(':'))
CSW_RECORD_URL = os.getenv('CSW_RECORD_URL', None)
# # tuples like (version, revision)
MICKA_ACCEPTED_VERSIONS = [
('2020.014', '2020-04-15.01'),
] if ':' not in os.getenv('MICKA_ACCEPTED_VERSION', '') else [
tuple(os.environ['MICKA_ACCEPTED_VERSION'].split(':'))
]
LAYMAN_PUBLIC_URL_SCHEME = urlparse(LAYMAN_CLIENT_PUBLIC_URL).scheme
REST_USERS_PREFIX = 'users'
REST_WORKSPACES_PREFIX = 'workspaces'
RESERVED_WORKSPACE_NAMES = {REST_USERS_PREFIX, REST_WORKSPACES_PREFIX}
# PREFERRED_LANGUAGES = ['cs', 'en']
# Bounding box used if data file is empty (in EPSG:3857)
LAYMAN_DEFAULT_OUTPUT_BBOX = (
-20026376.39,
-20048966.10,
20026376.39,
20048966.10,
)
# If bounding box of layman.layer has no area in at least one dimension,
# this padding in meters will be added to all dimensions whose coordinates equal
# for GeoServer feature type definiton and thumbnail rendering.
# E.g. if bbox is [5, 100, 5, 200] and NO_AREA_BBOX_PADDING = 10,
# thumbnail will be rendered with bbox [-5, 100, 15, 200].
NO_AREA_BBOX_PADDING = 10