maleo-foundation 0.1.22__py3-none-any.whl → 0.1.23__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.
- maleo_foundation/managers/middleware.py +4 -13
- maleo_foundation/middlewares/authentication.py +7 -4
- {maleo_foundation-0.1.22.dist-info → maleo_foundation-0.1.23.dist-info}/METADATA +1 -1
- {maleo_foundation-0.1.22.dist-info → maleo_foundation-0.1.23.dist-info}/RECORD +6 -6
- {maleo_foundation-0.1.22.dist-info → maleo_foundation-0.1.23.dist-info}/WHEEL +0 -0
- {maleo_foundation-0.1.22.dist-info → maleo_foundation-0.1.23.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
from fastapi import FastAPI
|
2
2
|
from pydantic import BaseModel, Field
|
3
3
|
from typing import List, Optional
|
4
|
-
from maleo_foundation.middlewares.authentication import
|
4
|
+
from maleo_foundation.middlewares.authentication import add_authentication_middleware
|
5
5
|
from maleo_foundation.middlewares.base import add_base_middleware, RequestProcessor
|
6
6
|
from maleo_foundation.middlewares.cors import add_cors_middleware
|
7
7
|
from maleo_foundation.utils.logging import MiddlewareLogger
|
@@ -46,16 +46,11 @@ class MiddlewareManager:
|
|
46
46
|
self,
|
47
47
|
loggers:MiddlewareLoggers,
|
48
48
|
key:str,
|
49
|
-
authentication_backend:Optional[Backend] = None,
|
50
49
|
request_processor:Optional[RequestProcessor] = None
|
51
50
|
):
|
52
51
|
self.add_cors()
|
53
52
|
self.add_base(logger=loggers.base, request_processor=request_processor)
|
54
|
-
|
55
|
-
self._authentication_backend = Backend(logger=loggers.authentication, key=key)
|
56
|
-
else:
|
57
|
-
self._authentication_backend = authentication_backend
|
58
|
-
self.add_authentication(backend=self._authentication_backend)
|
53
|
+
self.add_authentication(logger=loggers.authentication, key=key)
|
59
54
|
|
60
55
|
def add_cors(self) -> None:
|
61
56
|
add_cors_middleware(
|
@@ -82,9 +77,5 @@ class MiddlewareManager:
|
|
82
77
|
request_processor=request_processor
|
83
78
|
)
|
84
79
|
|
85
|
-
def add_authentication(self, logger:MiddlewareLogger, key:str
|
86
|
-
|
87
|
-
self._authentication_backend = Backend(logger=logger, key=key)
|
88
|
-
else:
|
89
|
-
self._authentication_backend = backend
|
90
|
-
add_authentication_middleware(app=self._app, backend=self._authentication_backend)
|
80
|
+
def add_authentication(self, logger:MiddlewareLogger, key:str):
|
81
|
+
add_authentication_middleware(app=self._app, logger=logger, key=key)
|
@@ -36,7 +36,7 @@ class Backend(AuthenticationBackend):
|
|
36
36
|
self._logger.info(f"Authentication - Request | IP: {client_ip} | URL: {conn.url.path} - Result | Username: {decode_token_result.data.u_u} | Email: {decode_token_result.data.u_e}")
|
37
37
|
return Credentials(token=token), User(authenticated=True, username=decode_token_result.data.u_u, email=decode_token_result.data.u_e)
|
38
38
|
|
39
|
-
def add_authentication_middleware(app:FastAPI,
|
39
|
+
def add_authentication_middleware(app:FastAPI, logger:MiddlewareLogger, key:str) -> None:
|
40
40
|
"""
|
41
41
|
Adds Authentication middleware to the FastAPI application.
|
42
42
|
|
@@ -44,8 +44,11 @@ def add_authentication_middleware(app:FastAPI, backend:Backend) -> None:
|
|
44
44
|
app: FastAPI
|
45
45
|
The FastAPI application instance to which the middleware will be added.
|
46
46
|
|
47
|
-
|
48
|
-
|
47
|
+
logger: MiddlewareLogger
|
48
|
+
Authentication middleware logger to be used.
|
49
|
+
|
50
|
+
key: str
|
51
|
+
Public key to be used for token decoding.
|
49
52
|
|
50
53
|
Returns:
|
51
54
|
None: The function modifies the FastAPI app by adding Base middleware.
|
@@ -59,4 +62,4 @@ def add_authentication_middleware(app:FastAPI, backend:Backend) -> None:
|
|
59
62
|
add_authentication_middleware(app=app, limit=10, window=1, cleanup_interval=60, ip_timeout=300)
|
60
63
|
```
|
61
64
|
"""
|
62
|
-
app.add_middleware(AuthenticationMiddleware, backend=
|
65
|
+
app.add_middleware(AuthenticationMiddleware, backend=Backend(logger=logger, key=key))
|
@@ -31,7 +31,7 @@ maleo_foundation/expanded_types/service.py,sha256=q8jpKdbCbLWwH1UPQavKpVE14rC5rv
|
|
31
31
|
maleo_foundation/expanded_types/token.py,sha256=4fRTJw6W5MYq71NksNrWNi7qYHQ4_lQwfu9WxwrMipc,355
|
32
32
|
maleo_foundation/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
33
33
|
maleo_foundation/managers/db.py,sha256=Jf0w-9JOAG5X2quDxqqw6d2WUIX7MYGdlPGxWP0rxHs,4699
|
34
|
-
maleo_foundation/managers/middleware.py,sha256=
|
34
|
+
maleo_foundation/managers/middleware.py,sha256=7CDXPMb28AR7J72TWOeKFxOlMypKezEtO9mr53a88B0,4032
|
35
35
|
maleo_foundation/managers/service.py,sha256=RSjaJDjrvzfTE2z0IYpzJMKYnl4BFaF7UEPl3uupH5k,19215
|
36
36
|
maleo_foundation/managers/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
37
37
|
maleo_foundation/managers/client/base.py,sha256=K8AFV2MTZrC1jbTqxkx7eedmxodJirNIjoRXGGcppy4,1022
|
@@ -42,7 +42,7 @@ maleo_foundation/managers/client/google/base.py,sha256=1lrGoyGnYW5Xq05bVXbKqnsqq
|
|
42
42
|
maleo_foundation/managers/client/google/secret.py,sha256=bWR_3Xl_wUFqj4M48w8ZE692U7PQKX9ap0ndDJviV80,3074
|
43
43
|
maleo_foundation/managers/client/google/storage.py,sha256=041iSSaFubnZrP-pS8MiLVtOgeLQ591Iz64JekZ5K7o,2350
|
44
44
|
maleo_foundation/middlewares/__init__.py,sha256=bqE2EIFC3rWcR2AwFPR0fk2kSFfeTRzgA24GbnuT5RA,3697
|
45
|
-
maleo_foundation/middlewares/authentication.py,sha256=
|
45
|
+
maleo_foundation/middlewares/authentication.py,sha256=y67sWz6FLl6NAtUWyK4mxC661dsBeKsDYRH3o7L_ZFQ,3188
|
46
46
|
maleo_foundation/middlewares/base.py,sha256=3OaB5F57F3epKNieoAgarYM6PimoUdUl3DgpadtVuqs,11743
|
47
47
|
maleo_foundation/middlewares/cors.py,sha256=9uvBvY2N6Vxa9RP_YtESxcWo6Doi6uS0lzAG9iLY7Uc,2288
|
48
48
|
maleo_foundation/models/__init__.py,sha256=AaKehO7c1HyKhoTGRmNHDddSeBXkW-_YNrpOGBu8Ms8,246
|
@@ -83,7 +83,7 @@ maleo_foundation/utils/logging.py,sha256=MwvZmZSA8SIdfq-knEvpYIgqnSpHcyHrZY9TVHW
|
|
83
83
|
maleo_foundation/utils/query.py,sha256=ODQ3adOYQNj5E2cRW9ytbjBz56nEDcnfq8mQ6YZbCCM,4375
|
84
84
|
maleo_foundation/utils/formatter/__init__.py,sha256=iKf5YCbEdg1qKnFHyKqqcQbqAqEeRUf8mhI3v3dQoj8,78
|
85
85
|
maleo_foundation/utils/formatter/case.py,sha256=TmvvlfzGdC_omMTB5vAa40TZBxQ3hnr-SYeo0M52Rlg,1352
|
86
|
-
maleo_foundation-0.1.
|
87
|
-
maleo_foundation-0.1.
|
88
|
-
maleo_foundation-0.1.
|
89
|
-
maleo_foundation-0.1.
|
86
|
+
maleo_foundation-0.1.23.dist-info/METADATA,sha256=IyQWkb3bbyLlrfs-ah3AIHil03lB2s4zsOovEZ3FJOg,3190
|
87
|
+
maleo_foundation-0.1.23.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
88
|
+
maleo_foundation-0.1.23.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
|
89
|
+
maleo_foundation-0.1.23.dist-info/RECORD,,
|
File without changes
|
File without changes
|