fastlifeweb 0.16.1__py3-none-any.whl → 0.16.3__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.
@@ -145,6 +145,7 @@ class GenericConfigurator(Generic[TRegistry]):
145
145
  str, "type[AbstractSecurityPolicy[Any, TRegistry]]"
146
146
  ] = {}
147
147
 
148
+ self._registered_permissions: set[str] = set()
148
149
  self.scanner = venusian.Scanner(fastlife=self)
149
150
  self.include("fastlife.views")
150
151
  self.include("fastlife.middlewares")
@@ -153,6 +154,15 @@ class GenericConfigurator(Generic[TRegistry]):
153
154
  def _current_router(self) -> Router:
154
155
  return self._routers[self._route_prefix]
155
156
 
157
+ @property
158
+ def all_registered_permissions(self) -> Sequence[str]:
159
+ """
160
+ Get the list of registered permissions.
161
+
162
+ This is usefull for introspection or testing purpose.
163
+ """
164
+ return sorted(self._registered_permissions)
165
+
156
166
  def build_asgi_app(self) -> FastAPI:
157
167
  """
158
168
  Build the app after configuration in order to start after beeing configured.
@@ -404,6 +414,7 @@ class GenericConfigurator(Generic[TRegistry]):
404
414
  """
405
415
  dependencies: list[DependsType] = []
406
416
  if permission:
417
+ self._registered_permissions.add(permission)
407
418
  dependencies.append(Depends(check_permission(permission)))
408
419
 
409
420
  self._current_router.add_api_route(
@@ -465,6 +476,7 @@ class GenericConfigurator(Generic[TRegistry]):
465
476
  """
466
477
  dependencies: list[DependsType] = []
467
478
  if permission:
479
+ self._registered_permissions.add(permission)
468
480
  dependencies.append(Depends(check_permission(permission)))
469
481
 
470
482
  if template:
@@ -15,6 +15,17 @@ def get_header(headers: Sequence[Tuple[bytes, bytes]], key: bytes) -> Optional[s
15
15
  return None
16
16
 
17
17
 
18
+ def get_header_int(headers: Sequence[Tuple[bytes, bytes]], key: bytes) -> Optional[int]:
19
+ for hdr in headers:
20
+ if hdr[0].lower() == key:
21
+ ret = hdr[1].decode("latin1")
22
+ try:
23
+ return int(ret)
24
+ except ValueError:
25
+ pass
26
+ return None
27
+
28
+
18
29
  class XForwardedStar(AbstractMiddleware):
19
30
  def __init__(
20
31
  self,
@@ -26,7 +37,10 @@ class XForwardedStar(AbstractMiddleware):
26
37
  if scope["type"] in ("http", "websocket"):
27
38
  headers = scope["headers"]
28
39
  new_vals = {
29
- "client": get_header(headers, b"x-real-ip"),
40
+ "client": (
41
+ get_header(headers, b"x-real-ip"),
42
+ get_header_int(headers, b"x-forwarded-port"),
43
+ ),
30
44
  "host": get_header(headers, b"x-forwarded-host"),
31
45
  "scheme": get_header(headers, b"x-forwarded-proto"),
32
46
  }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastlifeweb
3
- Version: 0.16.1
3
+ Version: 0.16.3
4
4
  Summary: High-level web framework
5
5
  Home-page: https://github.com/mardiros/fastlife
6
6
  License: BSD-derived
@@ -1666,7 +1666,7 @@ fastlife/components/pydantic_form/Textarea.jinja,sha256=NzfCi5agRUSVcb5RXw0QamM8
1666
1666
  fastlife/components/pydantic_form/Union.jinja,sha256=czTska54z9KCZKu-FaycLmOvtH6y6CGUFQ8DHnkjrJk,1461
1667
1667
  fastlife/components/pydantic_form/Widget.jinja,sha256=EXskDqt22D5grpGVwlZA3ndve2Wr_6yQH4qVE9c31Og,397
1668
1668
  fastlife/config/__init__.py,sha256=ThosRIPZ_fpD0exZu-kUC_f8ZNa5KyDlleWMmEHkjEo,448
1669
- fastlife/config/configurator.py,sha256=5In_ciAxqORR47gKIbZKTd1IOkkMO0a0iB4q5x7ltaI,21955
1669
+ fastlife/config/configurator.py,sha256=-U-se932t95YiIfPD6N-CElWuuqbKP2AKTjJXoajCKE,22385
1670
1670
  fastlife/config/exceptions.py,sha256=2MS2MFgb3mDbtdHEwnC-QYubob3Rl0v8O8y615LY0ds,1180
1671
1671
  fastlife/config/openapiextra.py,sha256=_9rBYeTqB7nVuzvUHMwZU387bTfYFHYLlP05NP0vEDs,513
1672
1672
  fastlife/config/registry.py,sha256=dGcNm7E6WY0x5HZNzo1gBFvGFCWeJj6JFXsJtLax5NU,1347
@@ -1676,7 +1676,7 @@ fastlife/config/views.py,sha256=Dxi6lO4gFs6GriAW7Rh5GDvebwbrpS2HzYhf30pXJiE,2058
1676
1676
  fastlife/middlewares/__init__.py,sha256=C3DUOzR5EhlAv5Zq7h-Abyvkd7bUsJohTRSB2wpRYQE,220
1677
1677
  fastlife/middlewares/base.py,sha256=9OYqByRuVoIrLt353NOedPQTLdr7LSmxhb2BZcp20qk,638
1678
1678
  fastlife/middlewares/reverse_proxy/__init__.py,sha256=g1SoVDmenKzpAAPYHTEsWgdBByOxtLg9fGx6RV3i0ok,846
1679
- fastlife/middlewares/reverse_proxy/x_forwarded.py,sha256=WC4xV3i6_Ogqsf_Zgt1ESml8zfnPbJJJkPlC2gTEqW8,1095
1679
+ fastlife/middlewares/reverse_proxy/x_forwarded.py,sha256=aq_80V0Vrb4M6RQfk8CtQnhfwZGzJyeTYYQ16In8DaQ,1510
1680
1680
  fastlife/middlewares/session/__init__.py,sha256=3XgXcIO6yQls5G7x8K2T8b7a_enA_7rQptWZcp3j2Ak,1400
1681
1681
  fastlife/middlewares/session/middleware.py,sha256=AlRIFXfn3JesKJzMAFUHDOo22mfuwDHkyecDHo9jCdA,3172
1682
1682
  fastlife/middlewares/session/serializer.py,sha256=fTdZCop0y4VkCMyOIo6GEbo5fVWrwsBXaSWfConPL8E,2144
@@ -1707,7 +1707,7 @@ fastlife/testing/__init__.py,sha256=vuqwoNUd3BuIp3fm7nkvmYkIGjIimf5zUGhDkeWrg2s,
1707
1707
  fastlife/testing/testclient.py,sha256=BC7lLQ_jc59UmknAKzgRtW9a3cpX_V_QLp9Mg2ScLA8,20546
1708
1708
  fastlife/views/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1709
1709
  fastlife/views/pydantic_form.py,sha256=ZYOXKudmSqtRvFn5ZY75DOXZVunGXJBKpjh9FJcqu6k,1386
1710
- fastlifeweb-0.16.1.dist-info/LICENSE,sha256=F75xSseSKMwqzFj8rswYU6NWS3VoWOc_gY3fJYf9_LI,1504
1711
- fastlifeweb-0.16.1.dist-info/METADATA,sha256=La4IIIjXXg0eXH5pyshmlUCJdW4InYOusZ-h6oSYtiU,3345
1712
- fastlifeweb-0.16.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
1713
- fastlifeweb-0.16.1.dist-info/RECORD,,
1710
+ fastlifeweb-0.16.3.dist-info/LICENSE,sha256=F75xSseSKMwqzFj8rswYU6NWS3VoWOc_gY3fJYf9_LI,1504
1711
+ fastlifeweb-0.16.3.dist-info/METADATA,sha256=oKBtNXGfKC8ya3PoQYclQuJVP_UPZs4GzKmWUzt3_t8,3345
1712
+ fastlifeweb-0.16.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
1713
+ fastlifeweb-0.16.3.dist-info/RECORD,,