geovisio 2.5.0__py3-none-any.whl → 2.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- geovisio/__init__.py +38 -8
- geovisio/admin_cli/__init__.py +2 -2
- geovisio/admin_cli/db.py +8 -0
- geovisio/config_app.py +64 -0
- geovisio/db_migrations.py +24 -3
- geovisio/templates/main.html +14 -14
- geovisio/templates/viewer.html +3 -3
- geovisio/translations/de/LC_MESSAGES/messages.mo +0 -0
- geovisio/translations/de/LC_MESSAGES/messages.po +667 -0
- geovisio/translations/en/LC_MESSAGES/messages.mo +0 -0
- geovisio/translations/en/LC_MESSAGES/messages.po +730 -0
- geovisio/translations/es/LC_MESSAGES/messages.mo +0 -0
- geovisio/translations/es/LC_MESSAGES/messages.po +778 -0
- geovisio/translations/fi/LC_MESSAGES/messages.mo +0 -0
- geovisio/translations/fi/LC_MESSAGES/messages.po +589 -0
- geovisio/translations/fr/LC_MESSAGES/messages.mo +0 -0
- geovisio/translations/fr/LC_MESSAGES/messages.po +814 -0
- geovisio/translations/ko/LC_MESSAGES/messages.mo +0 -0
- geovisio/translations/ko/LC_MESSAGES/messages.po +685 -0
- geovisio/translations/messages.pot +686 -0
- geovisio/translations/nl/LC_MESSAGES/messages.mo +0 -0
- geovisio/translations/nl/LC_MESSAGES/messages.po +594 -0
- geovisio/utils/__init__.py +1 -1
- geovisio/utils/auth.py +50 -11
- geovisio/utils/db.py +65 -0
- geovisio/utils/excluded_areas.py +83 -0
- geovisio/utils/extent.py +30 -0
- geovisio/utils/fields.py +1 -1
- geovisio/utils/filesystems.py +0 -1
- geovisio/utils/link.py +14 -0
- geovisio/utils/params.py +20 -0
- geovisio/utils/pictures.py +94 -69
- geovisio/utils/reports.py +171 -0
- geovisio/utils/sequences.py +288 -126
- geovisio/utils/tokens.py +37 -42
- geovisio/utils/upload_set.py +654 -0
- geovisio/web/auth.py +50 -37
- geovisio/web/collections.py +305 -319
- geovisio/web/configuration.py +14 -0
- geovisio/web/docs.py +288 -12
- geovisio/web/excluded_areas.py +377 -0
- geovisio/web/items.py +203 -151
- geovisio/web/map.py +322 -106
- geovisio/web/params.py +69 -26
- geovisio/web/pictures.py +14 -31
- geovisio/web/reports.py +399 -0
- geovisio/web/rss.py +13 -7
- geovisio/web/stac.py +129 -121
- geovisio/web/tokens.py +105 -112
- geovisio/web/upload_set.py +768 -0
- geovisio/web/users.py +100 -73
- geovisio/web/utils.py +38 -9
- geovisio/workers/runner_pictures.py +278 -183
- geovisio-2.7.0.dist-info/METADATA +95 -0
- geovisio-2.7.0.dist-info/RECORD +66 -0
- geovisio-2.5.0.dist-info/METADATA +0 -115
- geovisio-2.5.0.dist-info/RECORD +0 -41
- {geovisio-2.5.0.dist-info → geovisio-2.7.0.dist-info}/LICENSE +0 -0
- {geovisio-2.5.0.dist-info → geovisio-2.7.0.dist-info}/WHEEL +0 -0
geovisio/utils/tokens.py
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
from geovisio import errors
|
|
2
|
-
from geovisio.utils import auth
|
|
2
|
+
from geovisio.utils import auth, db
|
|
3
3
|
from geovisio.web.tokens import _decode_jwt_token, _generate_jwt_token
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import psycopg
|
|
7
4
|
from authlib.jose.errors import BadSignatureError
|
|
8
5
|
from flask import current_app
|
|
6
|
+
from flask_babel import gettext as _
|
|
9
7
|
from psycopg.rows import dict_row
|
|
10
8
|
|
|
11
9
|
|
|
@@ -14,7 +12,7 @@ import logging
|
|
|
14
12
|
|
|
15
13
|
class InvalidTokenException(errors.InvalidAPIUsage):
|
|
16
14
|
def __init__(self, details, status_code=401):
|
|
17
|
-
msg =
|
|
15
|
+
msg = "Token not valid"
|
|
18
16
|
super().__init__(msg, status_code=status_code, payload={"details": {"error": details}})
|
|
19
17
|
|
|
20
18
|
|
|
@@ -39,39 +37,37 @@ def get_account_from_jwt_token(jwt_token: str) -> auth.Account:
|
|
|
39
37
|
"""
|
|
40
38
|
try:
|
|
41
39
|
decoded = _decode_jwt_token(jwt_token)
|
|
42
|
-
except BadSignatureError
|
|
40
|
+
except BadSignatureError:
|
|
43
41
|
logging.exception("invalid signature of jwt token")
|
|
44
|
-
raise InvalidTokenException("JWT token signature does not match")
|
|
42
|
+
raise InvalidTokenException(_("JWT token signature does not match"))
|
|
45
43
|
token_id = decoded["sub"]
|
|
46
44
|
|
|
47
|
-
with
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if not records["id"]:
|
|
64
|
-
raise InvalidTokenException(
|
|
65
|
-
"Token not yet claimed, this token cannot be used yet. Either claim this token or generate a new one", status_code=403
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
return auth.Account(
|
|
69
|
-
id=str(records["id"]),
|
|
70
|
-
name=records["name"],
|
|
71
|
-
oauth_provider=records["oauth_provider"],
|
|
72
|
-
oauth_id=records["oauth_id"],
|
|
45
|
+
with db.cursor(current_app, row_factory=dict_row) as cursor:
|
|
46
|
+
# check token existence
|
|
47
|
+
records = cursor.execute(
|
|
48
|
+
"""SELECT
|
|
49
|
+
t.account_id AS id, a.name, a.oauth_provider, a.oauth_id, a.role
|
|
50
|
+
FROM tokens t
|
|
51
|
+
LEFT OUTER JOIN accounts a ON t.account_id = a.id
|
|
52
|
+
WHERE t.id = %(token)s""",
|
|
53
|
+
{"token": token_id},
|
|
54
|
+
).fetchone()
|
|
55
|
+
if not records:
|
|
56
|
+
raise InvalidTokenException(_("Token does not exist anymore"), status_code=403)
|
|
57
|
+
|
|
58
|
+
if not records["id"]:
|
|
59
|
+
raise InvalidTokenException(
|
|
60
|
+
_("Token not yet claimed, this token cannot be used yet. Either claim this token or generate a new one"), status_code=403
|
|
73
61
|
)
|
|
74
62
|
|
|
63
|
+
return auth.Account(
|
|
64
|
+
id=str(records["id"]),
|
|
65
|
+
name=records["name"],
|
|
66
|
+
oauth_provider=records["oauth_provider"],
|
|
67
|
+
oauth_id=records["oauth_id"],
|
|
68
|
+
role=auth.AccountRole[records["role"]],
|
|
69
|
+
)
|
|
70
|
+
|
|
75
71
|
|
|
76
72
|
def get_default_account_jwt_token() -> str:
|
|
77
73
|
"""
|
|
@@ -80,18 +76,17 @@ def get_default_account_jwt_token() -> str:
|
|
|
80
76
|
Note: do not expose this method externally, only an instance administrator should be able to get the default account JWT token!
|
|
81
77
|
"""
|
|
82
78
|
|
|
83
|
-
with
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"""
|
|
79
|
+
with db.cursor(current_app, row_factory=dict_row) as cursor:
|
|
80
|
+
# check token existence
|
|
81
|
+
records = cursor.execute(
|
|
82
|
+
"""
|
|
88
83
|
SELECT t.id AS id
|
|
89
84
|
FROM tokens t
|
|
90
85
|
JOIN accounts a ON t.account_id = a.id
|
|
91
86
|
WHERE a.is_default
|
|
92
87
|
"""
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
88
|
+
).fetchone()
|
|
89
|
+
if not records:
|
|
90
|
+
raise Exception("Default account has no associated token")
|
|
96
91
|
|
|
97
|
-
|
|
92
|
+
return _generate_jwt_token(records["id"])
|