c2cgeoportal-geoportal 2.9.0.178__py3-none-any.whl → 2.9.0.180__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.
@@ -42,10 +42,8 @@ import c2cwsgiutils.db
42
42
  import c2cwsgiutils.index
43
43
  import dateutil.parser
44
44
  import pyramid.config
45
- import pyramid.renderers
46
45
  import pyramid.request
47
46
  import pyramid.response
48
- import pyramid.security
49
47
  import sqlalchemy
50
48
  import sqlalchemy.orm
51
49
  import zope.event.classhandler
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2024, Camptocamp SA
1
+ # Copyright (c) 2024-2025, Camptocamp SA
2
2
  # All rights reserved.
3
3
 
4
4
  # Redistribution and use in source and binary forms, with or without
@@ -28,6 +28,7 @@
28
28
  import datetime
29
29
  import json
30
30
  import logging
31
+ import string
31
32
  from typing import TYPE_CHECKING, Any, NamedTuple, Optional, TypedDict, Union
32
33
 
33
34
  import pyramid.request
@@ -77,7 +78,7 @@ def get_oidc_client(request: pyramid.request.Request, host: str) -> simple_openi
77
78
  url=openid_connect["url"],
78
79
  authentication_redirect_uri=request.route_url("oidc_callback"),
79
80
  client_id=openid_connect["client_id"],
80
- client_secret=openid_connect.get("client-secret"),
81
+ client_secret=openid_connect.get("client_secret"),
81
82
  scope=" ".join(openid_connect.get("scopes", ["openid", "profile", "email"])),
82
83
  )
83
84
 
@@ -124,16 +125,31 @@ def get_remember_from_user_info(
124
125
  ("settings_role", None),
125
126
  ("roles", None),
126
127
  ):
127
- user_info_field = settings_fields.get(field_, default_field)
128
- if user_info_field is not None:
129
- if user_info_field not in user_info:
130
- _LOG.error(
131
- "Field '%s' not found in user info, available: %s.",
132
- user_info_field,
133
- ", ".join(user_info.keys()),
134
- )
135
- raise HTTPInternalServerError(f"Field '{user_info_field}' not found in user info.")
136
- remember_object[field_] = user_info[user_info_field] # type: ignore[literal-required]
128
+ _LOG.debug("User info keys: %s", ", ".join(user_info.keys()))
129
+ user_info_field_template = settings_fields.get(field_, default_field)
130
+ if user_info_field_template is not None:
131
+ if "{" in user_info_field_template:
132
+ formatter = string.Formatter()
133
+ attributes = formatter.parse(user_info_field_template)
134
+ user_info_fields = [e[1] for e in attributes if e[1] is not None]
135
+ else:
136
+ user_info_fields = [user_info_field_template]
137
+
138
+ for user_info_field in user_info_fields:
139
+ if user_info_field not in user_info:
140
+ _LOG.error(
141
+ "Field '%s' not found in user info, available: %s.",
142
+ user_info_field,
143
+ ", ".join(user_info.keys()),
144
+ )
145
+ raise HTTPInternalServerError(f"Field '{user_info_field}' not found in user info.")
146
+
147
+ user_info_value = (
148
+ user_info_field_template.format(**user_info)
149
+ if "{" in user_info_field_template
150
+ else user_info[user_info_field_template]
151
+ )
152
+ remember_object[field_] = user_info_value # type: ignore[literal-required]
137
153
 
138
154
 
139
155
  def get_user_from_remember(
@@ -194,6 +210,11 @@ def get_user_from_remember(
194
210
  user = static.User(username=username, email=email, display_name=display_name)
195
211
  models.DBSession.add(user)
196
212
  else:
213
+ roles = []
214
+ role_names = remember_object.get("roles", [])
215
+ if role_names:
216
+ query = models.DBSession.query(main.Role).filter(main.Role.name.in_(role_names))
217
+ roles = query.all()
197
218
  user = DynamicUser(
198
219
  id=-1,
199
220
  username=username,
@@ -204,10 +225,7 @@ def get_user_from_remember(
204
225
  if remember_object.get("settings_role") is not None
205
226
  else None
206
227
  ),
207
- roles=[
208
- models.DBSession.query(main.Role).filter_by(name=role).one()
209
- for role in remember_object.get("roles", [])
210
- ],
228
+ roles=roles,
211
229
  )
212
230
  return user
213
231
 
@@ -1279,8 +1279,7 @@ class Theme:
1279
1279
  if not self.request.user:
1280
1280
  raise pyramid.httpexceptions.HTTPForbidden()
1281
1281
 
1282
- admin_roles = [r for r in self.request.user.roles if r.name == ("role_admin")]
1283
- if not admin_roles:
1282
+ if not self.request.has_permission("admin"):
1284
1283
  raise pyramid.httpexceptions.HTTPForbidden()
1285
1284
 
1286
1285
  self._ogc_server_clear_cache(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: c2cgeoportal-geoportal
3
- Version: 2.9.0.178
3
+ Version: 2.9.0.180
4
4
  Summary: c2cgeoportal geoportal
5
5
  Home-page: https://github.com/camptocamp/c2cgeoportal/
6
6
  Author: Camptocamp
@@ -1,4 +1,4 @@
1
- c2cgeoportal_geoportal/__init__.py,sha256=uIVjYbQbRdoMC98xa2cScOPHYjb2rsvqFpLcEzbK2EE,38697
1
+ c2cgeoportal_geoportal/__init__.py,sha256=yy2McB6HK2pGoLYAZ8sjkwXl_uxdKOVVmynOovyO0ks,38648
2
2
  c2cgeoportal_geoportal/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  c2cgeoportal_geoportal/resources.py,sha256=n42Gns8DKw32GstDoUdNgud6xdAidaRwgAuNHqGH-c4,2158
4
4
  c2cgeoportal_geoportal/lib/__init__.py,sha256=_67fO_aXQZRnxPXcShHBcs38mdYU5ch0FNX89RwMTgA,10431
@@ -20,7 +20,7 @@ c2cgeoportal_geoportal/lib/lingva_extractor.py,sha256=pS-B5oTcEkW__XUop6rWKdpJhn
20
20
  c2cgeoportal_geoportal/lib/loader.py,sha256=vfjyuN2ry33Djc5KMTbibQ96uAw8oZyomAAwk0gbW5Q,2613
21
21
  c2cgeoportal_geoportal/lib/metrics.py,sha256=5HryUs6Rk6cmVvag5_FN-W2gcwsyJt3Xf9105TSO4mQ,4847
22
22
  c2cgeoportal_geoportal/lib/oauth2.py,sha256=1hXo78-8lg3OBvB0TK5zG5QawZnvroPhaVpTBtPZg8I,41107
23
- c2cgeoportal_geoportal/lib/oidc.py,sha256=BYAXXo-k6vKTvVJDkT317641YDMT4DnvHJFR945H9x0,12222
23
+ c2cgeoportal_geoportal/lib/oidc.py,sha256=r4O-htcKiyxUlzcNMkPJ3smaM7TkfHVT6bH1qYwm2Ss,13017
24
24
  c2cgeoportal_geoportal/lib/wmstparsing.py,sha256=EWFXxZ_nK3vpx8H3dSKIJTnNAXoJmfhhHYkcG1bXluI,12379
25
25
  c2cgeoportal_geoportal/lib/xsd.py,sha256=V5dXPWTVIz04LoI5GDkorFnaLrLUhlw--c6NzWsAxfk,7031
26
26
  c2cgeoportal_geoportal/scaffolds/advance_create/cookiecutter.json,sha256=1LVOM-j_nd00J89q0EI3bQUvIysbidApaVHDibA2ydk,524
@@ -171,10 +171,10 @@ c2cgeoportal_geoportal/views/proxy.py,sha256=XxOGR8Snqrd1CKkUiK4IjavCR8PiUsd3tlE
171
171
  c2cgeoportal_geoportal/views/raster.py,sha256=kY6rYo4SxQP9JLbsq3_kdWdbaTVkdQDdpjrG9lUtAIM,9242
172
172
  c2cgeoportal_geoportal/views/resourceproxy.py,sha256=pcHwU6hAXHeh_Ef6tuHxpRzGje8nqVKUxyZwZKOPCjI,3189
173
173
  c2cgeoportal_geoportal/views/shortener.py,sha256=t-05vHSbsp6aIYV6fKk-ic6Zo45TLePIlGnPAzwrzQU,6179
174
- c2cgeoportal_geoportal/views/theme.py,sha256=jSpQcI3x2Exo31ubHdF8_ApGIhET7MnH7p0DN6yQLDI,55924
174
+ c2cgeoportal_geoportal/views/theme.py,sha256=npI1Z-Z3304ZrLDnCOwxbQGTA0D9AsTr70VIEpJ1lVY,55862
175
175
  c2cgeoportal_geoportal/views/tinyowsproxy.py,sha256=_wPN1Vfo4RNcCQ1xRPU_funie7mDPocL-ox_4hlF1-Y,8178
176
176
  c2cgeoportal_geoportal/views/vector_tiles.py,sha256=2bF3j6WvOpXAJULsEfy7pfeUBeKVheMlcUOWzHVow90,3575
177
- tests/__init__.py,sha256=KxmbgvRWDSJoEDH1cXnDIjbfBsgCzs2KdkTPuzYMq84,3826
177
+ tests/__init__.py,sha256=QJY_VGdOehpa3uMdeiF0boDPvH8BVgxPWJRzyDTcvwA,3826
178
178
  tests/test_cachebuster.py,sha256=asI1X_qI0MGklYuKuWyqvCPVbvhQcUe4fX91Dk-hUsE,2923
179
179
  tests/test_caching.py,sha256=Juj7uwjOkjbPlTd-ll65SgWFzj3d2yDyf-eQ7ELk2eY,13222
180
180
  tests/test_checker.py,sha256=NaU6Ejg9XbwS2cwqXCtz5mJPRdBIPZb3d1MkXVufr0k,3638
@@ -187,8 +187,8 @@ tests/test_mapserverproxy_route_predicate.py,sha256=SzILSSzIuilzIkUYVPZiVzLwW1du
187
187
  tests/test_raster.py,sha256=82NJ2MXgZlMqs0ytN-VgNw376iURdk4PkAg__dyh5ns,11948
188
188
  tests/test_wmstparsing.py,sha256=xjA8nJuXFl3H5Bfs4sJw_8qX8E8qvAALK7Hs2-DTP2A,9054
189
189
  tests/xmlstr.py,sha256=rkTKSU4FGjupBKLx75H8o-goB0KbQrxDvdpc6xVX_uQ,5985
190
- c2cgeoportal_geoportal-2.9.0.178.dist-info/METADATA,sha256=afM3vHpFfG3vHBjwTfa65XwUcrnrd2EYJaBascjHGCY,1923
191
- c2cgeoportal_geoportal-2.9.0.178.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
192
- c2cgeoportal_geoportal-2.9.0.178.dist-info/entry_points.txt,sha256=3dnX260FsLX_AubeNMdyeta_z1X4CxcD3steAlfPx2I,1414
193
- c2cgeoportal_geoportal-2.9.0.178.dist-info/top_level.txt,sha256=PJIbY7Nx51dDrJ052f5mDA7c6Tehm5aD-Gb32L_CtJA,29
194
- c2cgeoportal_geoportal-2.9.0.178.dist-info/RECORD,,
190
+ c2cgeoportal_geoportal-2.9.0.180.dist-info/METADATA,sha256=8rsohSha4kU5yh2iX3ENMGIBe9pvS39xWgcXAn2qZb4,1923
191
+ c2cgeoportal_geoportal-2.9.0.180.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
192
+ c2cgeoportal_geoportal-2.9.0.180.dist-info/entry_points.txt,sha256=3dnX260FsLX_AubeNMdyeta_z1X4CxcD3steAlfPx2I,1414
193
+ c2cgeoportal_geoportal-2.9.0.180.dist-info/top_level.txt,sha256=PJIbY7Nx51dDrJ052f5mDA7c6Tehm5aD-Gb32L_CtJA,29
194
+ c2cgeoportal_geoportal-2.9.0.180.dist-info/RECORD,,
tests/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2011-2023, Camptocamp SA
1
+ # Copyright (c) 2011-2025, Camptocamp SA
2
2
  # All rights reserved.
3
3
 
4
4
  # Redistribution and use in source and binary forms, with or without