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/web/auth.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import flask
|
|
2
2
|
from flask import current_app, url_for, session, redirect, request, jsonify
|
|
3
|
-
import
|
|
4
|
-
from typing import Any
|
|
3
|
+
from flask_babel import gettext as _
|
|
5
4
|
from urllib.parse import quote
|
|
6
|
-
from geovisio import utils
|
|
5
|
+
from geovisio import utils, errors
|
|
6
|
+
from geovisio.utils import db
|
|
7
7
|
from geovisio.utils.auth import Account, ACCOUNT_KEY
|
|
8
|
+
from authlib.integrations.base_client.errors import MismatchingStateError
|
|
8
9
|
|
|
9
10
|
bp = flask.Blueprint("auth", __name__, url_prefix="/api/auth")
|
|
10
11
|
|
|
@@ -52,42 +53,54 @@ def auth():
|
|
|
52
53
|
schema:
|
|
53
54
|
type: string
|
|
54
55
|
"""
|
|
55
|
-
|
|
56
|
+
try:
|
|
57
|
+
tokenResponse = utils.auth.oauth_provider.client.authorize_access_token()
|
|
58
|
+
except MismatchingStateError as e:
|
|
59
|
+
raise errors.InternalError(
|
|
60
|
+
_("Impossible to finish authentication flow"),
|
|
61
|
+
payload={
|
|
62
|
+
"details": {
|
|
63
|
+
"error": str(e),
|
|
64
|
+
"tips": _("You can try to clear your cookies and retry. If the problem persists, contact your instance administrator."),
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
status_code=403,
|
|
68
|
+
)
|
|
56
69
|
|
|
57
70
|
oauth_info = utils.auth.oauth_provider.get_user_oauth_info(tokenResponse)
|
|
58
|
-
with
|
|
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
|
-
|
|
71
|
+
with db.cursor(current_app) as cursor:
|
|
72
|
+
res = cursor.execute(
|
|
73
|
+
"INSERT INTO accounts (name, oauth_provider, oauth_id) VALUES (%(name)s, %(provider)s, %(id)s) ON CONFLICT (oauth_provider, oauth_id) DO UPDATE SET name = %(name)s RETURNING id, name",
|
|
74
|
+
{
|
|
75
|
+
"provider": utils.auth.oauth_provider.name,
|
|
76
|
+
"id": oauth_info.id,
|
|
77
|
+
"name": oauth_info.name,
|
|
78
|
+
},
|
|
79
|
+
).fetchone()
|
|
80
|
+
if res is None:
|
|
81
|
+
raise Exception("Impossible to insert user in database")
|
|
82
|
+
id, name = res
|
|
83
|
+
account = Account(
|
|
84
|
+
id=str(id), # convert uuid to string for serialization
|
|
85
|
+
name=name,
|
|
86
|
+
oauth_provider=utils.auth.oauth_provider.name,
|
|
87
|
+
oauth_id=oauth_info.id,
|
|
88
|
+
)
|
|
89
|
+
session[ACCOUNT_KEY] = account.model_dump(exclude_none=True)
|
|
90
|
+
session.permanent = True
|
|
91
|
+
|
|
92
|
+
next_url = session.pop(NEXT_URL_KEY, None)
|
|
93
|
+
if next_url:
|
|
94
|
+
response = flask.make_response(redirect(next_url))
|
|
95
|
+
else:
|
|
96
|
+
response = flask.make_response(redirect("/"))
|
|
97
|
+
|
|
98
|
+
# also store id/name in cookies for the front end to use those
|
|
99
|
+
max_age = current_app.config["PERMANENT_SESSION_LIFETIME"]
|
|
100
|
+
_set_cookie(response, "user_id", str(id), max_age=max_age)
|
|
101
|
+
_set_cookie(response, "user_name", quote(name), max_age=max_age)
|
|
102
|
+
|
|
103
|
+
return response
|
|
91
104
|
|
|
92
105
|
|
|
93
106
|
@bp.route("/logout")
|