fastlifeweb 0.7.1__py3-none-any.whl → 0.7.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.
@@ -30,8 +30,8 @@ from fastlife.configurator.base import AbstractMiddleware
30
30
  from fastlife.configurator.route_handler import FastlifeRoute
31
31
  from fastlife.security.csrf import check_csrf
32
32
 
33
- from .settings import Settings
34
33
  from .route_handler import FastlifeRequest
34
+ from .settings import Settings
35
35
 
36
36
  if TYPE_CHECKING:
37
37
  from .registry import AppRegistry # coverage: ignore
@@ -64,7 +64,7 @@ class Configurator:
64
64
  self._app.router.route_class = FastlifeRoute
65
65
  self.scanner = venusian.Scanner(fastlife=self)
66
66
  self.include("fastlife.views")
67
- self.include("fastlife.session")
67
+ self.include("fastlife.middlewares")
68
68
 
69
69
  def get_app(self) -> FastAPI:
70
70
  """
@@ -1,4 +1,5 @@
1
1
  """Settings for the fastlife."""
2
+
2
3
  from datetime import timedelta
3
4
  from typing import Literal
4
5
 
@@ -77,7 +78,7 @@ class Settings(BaseSettings):
77
78
  should be true while using https on production.
78
79
  """
79
80
  session_serializer: str = Field(
80
- default="fastlife.session.serializer:SignedSessionSerializer"
81
+ default="fastlife.middlewares.session.serializer:SignedSessionSerializer"
81
82
  )
82
83
  """Cookie serializer for the session cookie."""
83
84
 
@@ -86,3 +87,6 @@ class Settings(BaseSettings):
86
87
 
87
88
  check_permission: str = Field(default="fastlife.security.policy:check_permission")
88
89
  """Handler for checking permission set on any views using the configurator."""
90
+
91
+ decode_reverse_proxy_headers: bool = Field(default=True)
92
+ """Ensure that the request object has information based on http proxy headers."""
@@ -0,0 +1,7 @@
1
+ from fastlife import Configurator, configure
2
+
3
+
4
+ @configure
5
+ def includeme(config: Configurator) -> None:
6
+ config.include(".reverse_proxy")
7
+ config.include(".session")
@@ -0,0 +1,10 @@
1
+ from fastlife import Configurator, configure
2
+
3
+ from .x_forwarded import XForwardedStar
4
+
5
+
6
+ @configure
7
+ def includeme(config: Configurator) -> None:
8
+ settings = config.registry.settings
9
+ if settings.decode_reverse_proxy_headers:
10
+ config.add_middleware(XForwardedStar)
@@ -0,0 +1,50 @@
1
+ """
2
+ A middleware that update the request scope for https behind a proxy.
3
+
4
+ The attempt of this middleware is to fix Starlette behavior that use client and scheme
5
+ header based on the header x-forwarded-* headers and the x-real-ip.
6
+
7
+ the x-forwarded-for header is not parsed to find the appropriate value,
8
+ the x-real-ip is used.
9
+ notethat the x-forwarded-port header is not used.
10
+
11
+ Note that uvicorn or hypercorn offer the same kind middleware.
12
+ """
13
+
14
+ import logging
15
+ from typing import Optional, Sequence, Tuple
16
+
17
+ from starlette.types import ASGIApp, Receive, Scope, Send
18
+
19
+ from fastlife.configurator.base import AbstractMiddleware
20
+
21
+
22
+ log = logging.getLogger(__name__)
23
+
24
+
25
+ def get_header(headers: Sequence[Tuple[bytes, bytes]], key: bytes) -> Optional[str]:
26
+ for hdr in headers:
27
+ if hdr[0].lower() == key:
28
+ return hdr[1].decode("latin1")
29
+ return None
30
+
31
+
32
+ class XForwardedStar(AbstractMiddleware):
33
+ def __init__(
34
+ self,
35
+ app: ASGIApp,
36
+ ) -> None:
37
+ self.app = app
38
+
39
+ async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
40
+ if scope["type"] in ("http", "websocket"):
41
+
42
+ headers = scope["headers"]
43
+ new_vals = {
44
+ "client": get_header(headers, b"x-real-ip"),
45
+ "host": get_header(headers, b"x-forwarded-host"),
46
+ "scheme": get_header(headers, b"x-forwarded-proto"),
47
+ }
48
+ scope.update({key: val for key, val in new_vals.items() if val is not None})
49
+
50
+ await self.app(scope, receive, send)
@@ -0,0 +1,7 @@
1
+ {# def
2
+ class_="table-auto w-full text-left border-colapse"
3
+ #}
4
+
5
+ <table class="{{attrs.class or class_}}">
6
+ {{- content -}}
7
+ </table>
@@ -0,0 +1,3 @@
1
+ <tbody>
2
+ {{- content -}}
3
+ </tbody>
@@ -0,0 +1,7 @@
1
+ {# def
2
+ class_="px-4 py-2 border-b dark:border-neutral-500"
3
+ #}
4
+
5
+ <td class="{{attrs.class or class_}}">
6
+ {{- content -}}
7
+ </td>
@@ -0,0 +1,3 @@
1
+ <tfoot>
2
+ {{- content -}}
3
+ </tfoot>
@@ -0,0 +1,7 @@
1
+ {# def
2
+ class_="px-4 py-2 border-b dark:border-neutral-500"
3
+ #}
4
+
5
+ <th class="{{attrs.class or class_}}">
6
+ {{- content -}}
7
+ </th>
@@ -0,0 +1,3 @@
1
+ <thead>
2
+ {{- content -}}
3
+ </thead>
@@ -0,0 +1,7 @@
1
+ {# def
2
+ class_=""
3
+ #}
4
+
5
+ <tr class="{{attrs.class or class_}}">
6
+ {{- content -}}
7
+ </tr>
@@ -14,7 +14,7 @@ from multidict import MultiDict
14
14
  from starlette.types import ASGIApp
15
15
 
16
16
  from fastlife.configurator.settings import Settings
17
- from fastlife.session.serializer import AbsractSessionSerializer
17
+ from fastlife.middlewares.session.serializer import AbsractSessionSerializer
18
18
  from fastlife.shared_utils.resolver import resolve
19
19
 
20
20
  CookieTypes = httpx._types.CookieTypes # type: ignore
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fastlifeweb
3
- Version: 0.7.1
3
+ Version: 0.7.3
4
4
  Summary: High-level web framework
5
5
  Home-page: https://github.com/mardiros/fastlife
6
6
  License: BSD-derived
@@ -1,10 +1,16 @@
1
1
  fastlife/__init__.py,sha256=nAeweHnTvWHgDZYuPIWawZvT4juuhvMp4hzF2B-yCJU,317
2
2
  fastlife/configurator/__init__.py,sha256=vMV25HEfuXjCL7DhZukhlB2JSfxwzX2lGbErcZ5b7N0,146
3
3
  fastlife/configurator/base.py,sha256=2ahvTudLmD99YQjnIeGN5JDPCSl3k-mauu7bsSEB5RE,216
4
- fastlife/configurator/configurator.py,sha256=3VnwA-ES9KumYc_XOJZq7O--qHeRceUldH66RaIy3bQ,7234
4
+ fastlife/configurator/configurator.py,sha256=1RzDS-BEQ5MjNv29QKnmRO-j50xJ4Noax-I8tcClRyQ,7238
5
5
  fastlife/configurator/registry.py,sha256=FKXCxWlMMGNN1-l5H6QLTCoqP_tWENN84RjkConejWI,1580
6
6
  fastlife/configurator/route_handler.py,sha256=TRsiGM8xQxJvRFbdKZphLK7l37DSfKvvmkEbg-h5EoU,977
7
- fastlife/configurator/settings.py,sha256=uyIZFLqzbwDAUkl8LWNYdlPifMR3ZItyC4y9ci_3LrM,3376
7
+ fastlife/configurator/settings.py,sha256=BzZrA8igijRwBQy_I8-dbXCTXw6c734Pg-xNRU4EDNU,3537
8
+ fastlife/middlewares/__init__.py,sha256=WiT5WDI_4ld5WXFmI_Q2He1T3kPakmAYmpR_bGuUZWE,171
9
+ fastlife/middlewares/reverse_proxy/__init__.py,sha256=geiPYm_h8A6cgkyy2AOBsokfeJjvO5iRQS5A2Ui6vN4,276
10
+ fastlife/middlewares/reverse_proxy/x_forwarded.py,sha256=K_WvXAP2Cdt-pFXYVPcAyh9yCKmEzJmOzdnS4hqgkG8,1542
11
+ fastlife/middlewares/session/__init__.py,sha256=OnzRCYRzc1lw9JB0UdKi-aRLPNT2n8mM8kwY1P4w7uU,838
12
+ fastlife/middlewares/session/middleware.py,sha256=JgXdBlxlm9zIEgXcidbBrMAp5wJVPsZWtvCLVDk5h2s,3049
13
+ fastlife/middlewares/session/serializer.py,sha256=qpVnHQjYTxw3aOnoEOKIjOFJg2z45KjiX5sipWk2gws,1458
8
14
  fastlife/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
15
  fastlife/request/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
16
  fastlife/request/form_data.py,sha256=mP8ilwRUY2WbktIkRgaJJ2EUjwUMPbSPg29GzwZgT18,3713
@@ -14,9 +20,6 @@ fastlife/routing/router.py,sha256=hHK4NumgTTXI330ZxQeZBiEfGtBRn4_k_fIh_xaaVtg,33
14
20
  fastlife/security/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
21
  fastlife/security/csrf.py,sha256=yDBF8X5jna-EZm7PPNvoaS_RJTYfTapwbghm506O9wM,1519
16
22
  fastlife/security/policy.py,sha256=7gnwooTz7iCDZ26hzulUK0vUz9Ncd7y1Lq_6Lr7CJ98,702
17
- fastlife/session/__init__.py,sha256=OnzRCYRzc1lw9JB0UdKi-aRLPNT2n8mM8kwY1P4w7uU,838
18
- fastlife/session/middleware.py,sha256=JgXdBlxlm9zIEgXcidbBrMAp5wJVPsZWtvCLVDk5h2s,3049
19
- fastlife/session/serializer.py,sha256=qpVnHQjYTxw3aOnoEOKIjOFJg2z45KjiX5sipWk2gws,1458
20
23
  fastlife/shared_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
24
  fastlife/shared_utils/infer.py,sha256=0jNPY5vqKvDlNCmVPnRAXbTcQnmbuOIOIGAeGcxDPok,472
22
25
  fastlife/shared_utils/resolver.py,sha256=wXQQTB4jf86m4qENhMOkHkWpLJj_T4-_eND_ItTLnTE,1410
@@ -38,6 +41,13 @@ fastlife/templates/Option.jinja,sha256=YlgBayJj94kSXK0mlGkMxTmHjTBr8T-UzvQmTcANK
38
41
  fastlife/templates/P.jinja,sha256=xEcHIv9dJRpELu_SdqQcftvKrU8z1i_BHTEVO5Mu5dU,164
39
42
  fastlife/templates/Radio.jinja,sha256=51I5n1yjWQ_uLZfzuUUf3C8ngo-KT4dPw29-pjP9uSU,723
40
43
  fastlife/templates/Select.jinja,sha256=GoK2oh4Jl5dAfL2wN718RCwtHaQIslzDCN_nwy6a9oY,480
44
+ fastlife/templates/Table.jinja,sha256=Zhqmb-otlp05h3WDliFfK3HkxHrhDoKL0cbH7GgS2aY,132
45
+ fastlife/templates/Tbody.jinja,sha256=K8wwTYcYi8-NYdP4g7MBokvYqJp9QW7DmChADuCa-Gs,35
46
+ fastlife/templates/Td.jinja,sha256=uRE-6nDYXoZhMot1bL55D888Xd19hJrjNWqoyxkQnMQ,126
47
+ fastlife/templates/Tfoot.jinja,sha256=iSHDcwhi7VNql5Yl3jvkrx2WVquT5Zm8to9P3WBlKYQ,35
48
+ fastlife/templates/Th.jinja,sha256=GdxKPkbdTNTR83PyOYr_M4IonyH99O-wjdi-7QBjAvg,126
49
+ fastlife/templates/Thead.jinja,sha256=gp3T4XiEk5zgih0gmmLcVke-Z8AgTol7AQrRtVev480,35
50
+ fastlife/templates/Tr.jinja,sha256=m999VbUMeHDkw_-JsXqtMEZsA9Zklr8eA-NiIk5FFm8,84
41
51
  fastlife/templates/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
52
  fastlife/templates/pydantic_form/Boolean.jinja,sha256=gf8j1Wyy8C95tYsjDjxKL_ivSJPsUHBoRaK-4AiBiBA,467
43
53
  fastlife/templates/pydantic_form/Checklist.jinja,sha256=s55FqHJGNryTT3h6VWFx6mEgR8lIVBoqo7NGYUTM_rE,775
@@ -67,10 +77,10 @@ fastlife/templating/renderer/widgets/sequence.py,sha256=rYXsUZokV3wnKa-26BmgAu7s
67
77
  fastlife/templating/renderer/widgets/text.py,sha256=OWFFA0muZCznrlUrBRRUKVj60TdWtsdgw0bURdOA3lE,879
68
78
  fastlife/templating/renderer/widgets/union.py,sha256=xNDctq0SRXfRyMHXL8FgRKyUOUreR1xENnt6onkZJ9I,1797
69
79
  fastlife/testing/__init__.py,sha256=vuqwoNUd3BuIp3fm7nkvmYkIGjIimf5zUGhDkeWrg2s,98
70
- fastlife/testing/testclient.py,sha256=wJtWXxn5cew8PlxweYvw7occnoD5Ktr_7IxEXi-Ieg0,20534
80
+ fastlife/testing/testclient.py,sha256=izNTkFgArIUrdSemNl3iiEDdsiUfnb2TtfKnZi3Jwv8,20546
71
81
  fastlife/views/__init__.py,sha256=nn4B_8YTbTmhGPvSd20yyKK_9Dh1Pfh_Iq7z6iK8-CE,154
72
82
  fastlife/views/pydantic_form.py,sha256=KJtH_DK8em0czGPsv0XpzGUFhtycyXdeRldwiU7d_j4,1257
73
- fastlifeweb-0.7.1.dist-info/LICENSE,sha256=F75xSseSKMwqzFj8rswYU6NWS3VoWOc_gY3fJYf9_LI,1504
74
- fastlifeweb-0.7.1.dist-info/METADATA,sha256=-dGK9zmf4PUfvKmBZmF5zCIbyJb_QmmgFI70rvOoDrk,1833
75
- fastlifeweb-0.7.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
76
- fastlifeweb-0.7.1.dist-info/RECORD,,
83
+ fastlifeweb-0.7.3.dist-info/LICENSE,sha256=F75xSseSKMwqzFj8rswYU6NWS3VoWOc_gY3fJYf9_LI,1504
84
+ fastlifeweb-0.7.3.dist-info/METADATA,sha256=N_VoUZaz4mwzEHd8apGxTLNMkFdlqdY53rmSo7dGO1A,1833
85
+ fastlifeweb-0.7.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
86
+ fastlifeweb-0.7.3.dist-info/RECORD,,
File without changes
File without changes
File without changes