maleo-foundation 0.3.72__tar.gz → 0.3.74__tar.gz
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-0.3.72 → maleo_foundation-0.3.74}/PKG-INFO +3 -1
- maleo_foundation-0.3.74/maleo_foundation/authentication.py +36 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/constants.py +2 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/enums.py +7 -1
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/middleware.py +8 -8
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/service.py +8 -4
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/middlewares/authentication.py +3 -2
- maleo_foundation-0.3.74/maleo_foundation/middlewares/base.py +589 -0
- maleo_foundation-0.3.74/maleo_foundation/models/schemas/general.py +116 -0
- maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/authentication.py +35 -0
- {maleo_foundation-0.3.72/maleo_foundation → maleo_foundation-0.3.74/maleo_foundation/models/transfers/general}/authorization.py +0 -3
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/__init__.py +2 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/middleware.py +6 -7
- maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/operation.py +213 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/request.py +13 -19
- maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/response.py +14 -0
- maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/service.py +9 -0
- maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/user_agent.py +34 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/exceptions/client.py +22 -23
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/exceptions/service.py +21 -22
- maleo_foundation-0.3.74/maleo_foundation/utils/extractor.py +97 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/logging.py +40 -0
- maleo_foundation-0.3.74/maleo_foundation/utils/parser.py +7 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/PKG-INFO +3 -1
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/SOURCES.txt +6 -4
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/requires.txt +2 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/pyproject.toml +3 -1
- maleo_foundation-0.3.72/maleo_foundation/authentication.py +0 -82
- maleo_foundation-0.3.72/maleo_foundation/middlewares/base.py +0 -474
- maleo_foundation-0.3.72/maleo_foundation/models/schemas/general.py +0 -242
- maleo_foundation-0.3.72/maleo_foundation/models/transfers/general/operation.py +0 -51
- maleo_foundation-0.3.72/maleo_foundation/utils/dependencies/__init__.py +0 -6
- maleo_foundation-0.3.72/maleo_foundation/utils/dependencies/auth.py +0 -17
- maleo_foundation-0.3.72/maleo_foundation/utils/dependencies/context.py +0 -8
- maleo_foundation-0.3.72/maleo_foundation/utils/extractor.py +0 -67
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/README.md +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/manager.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/encryption/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/encryption/aes.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/encryption/rsa.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/hash/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/hash/bcrypt.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/hash/hmac.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/hash/sha256.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/key.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/signature.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/token.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/controller_types.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/client.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/encryption/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/encryption/aes.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/encryption/rsa.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/general.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/hash.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/key.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/service.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/signature.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/token.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/extended_types.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/cache.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/base.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/base.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/parameter.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/secret.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/storage.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/subscription.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/maleo.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/configuration.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/credential.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/db.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/middlewares/cors.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/responses.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/encryption.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/hash.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/key.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/parameter.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/result.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/signature.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/token.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/table.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/cache/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/cache/redis.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/client/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/client/maleo.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/database.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/pubsub/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/pubsub/publisher.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/pubsub/subscription.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/service.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/credentials.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/data.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/database.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/key.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/settings.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/signature.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/token.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/client.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/encryption/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/encryption/aes.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/encryption/rsa.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/general.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/hash/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/hash/bcrypt.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/hash/hmac.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/hash/sha256.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/key.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/service.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/signature.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/token.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/client/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/client/controllers/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/client/controllers/http.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/client/service.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/encryption/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/encryption/aes.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/encryption/rsa.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/hash.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/key.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/service/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/service/controllers/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/service/controllers/rest.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/service/general.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/signature.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/token.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/rest_controller_result.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/types.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/cache.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/client.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/controller.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/exceptions/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/exceptions/request.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/formatter/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/formatter/case.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/credential/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/credential/google.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/json.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/key/__init__.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/key/rsa.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/yaml.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/merger.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/query.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/repository.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/searcher.py +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/dependency_links.txt +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/top_level.txt +0 -0
- {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: maleo_foundation
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.74
|
4
4
|
Summary: Foundation package for Maleo
|
5
5
|
Author-email: Agra Bima Yuda <agra@nexmedis.com>
|
6
6
|
License: MIT
|
@@ -98,6 +98,8 @@ Requires-Dist: starlette>=0.46.2
|
|
98
98
|
Requires-Dist: twine>=6.1.0
|
99
99
|
Requires-Dist: typing-inspection>=0.4.0
|
100
100
|
Requires-Dist: typing_extensions>=4.13.2
|
101
|
+
Requires-Dist: ua-parser>=1.0.1
|
102
|
+
Requires-Dist: ua-parser-builtins>=0.18.0.post1
|
101
103
|
Requires-Dist: urllib3>=2.4.0
|
102
104
|
Requires-Dist: uvicorn>=0.34.2
|
103
105
|
Requires-Dist: virtualenv>=20.31.2
|
@@ -0,0 +1,36 @@
|
|
1
|
+
from starlette.authentication import AuthCredentials, BaseUser
|
2
|
+
from typing import Optional, Sequence
|
3
|
+
from maleo_foundation.models.transfers.general.authentication import Token
|
4
|
+
|
5
|
+
|
6
|
+
class Credentials(AuthCredentials):
|
7
|
+
def __init__(
|
8
|
+
self, token: Optional[Token] = None, scopes: Optional[Sequence[str]] = None
|
9
|
+
) -> None:
|
10
|
+
self._token = token
|
11
|
+
super().__init__(scopes)
|
12
|
+
|
13
|
+
@property
|
14
|
+
def token(self) -> Optional[Token]:
|
15
|
+
return self._token
|
16
|
+
|
17
|
+
|
18
|
+
class User(BaseUser):
|
19
|
+
def __init__(
|
20
|
+
self, authenticated: bool = False, username: str = "", email: str = ""
|
21
|
+
) -> None:
|
22
|
+
self._authenticated = authenticated
|
23
|
+
self._username = username
|
24
|
+
self._email = email
|
25
|
+
|
26
|
+
@property
|
27
|
+
def is_authenticated(self) -> bool:
|
28
|
+
return self._authenticated
|
29
|
+
|
30
|
+
@property
|
31
|
+
def display_name(self) -> str:
|
32
|
+
return self._username
|
33
|
+
|
34
|
+
@property
|
35
|
+
def identity(self) -> str:
|
36
|
+
return self._email
|
@@ -1,9 +1,11 @@
|
|
1
1
|
import re
|
2
|
+
from fastapi.security import HTTPBearer
|
2
3
|
from typing import List
|
3
4
|
from uuid import UUID
|
4
5
|
from maleo_foundation.enums import BaseEnums
|
5
6
|
from maleo_foundation.types import BaseTypes
|
6
7
|
|
8
|
+
TOKEN_SCHEME = HTTPBearer()
|
7
9
|
EMAIL_REGEX: str = r"^[^\s@]+@[^\s@]+\.[^\s@]+$"
|
8
10
|
TOKEN_COOKIE_KEY_NAME = "token"
|
9
11
|
REFRESH_TOKEN_DURATION_DAYS: int = 7
|
@@ -69,10 +69,12 @@ class BaseEnums:
|
|
69
69
|
|
70
70
|
class ExceptionType(StrEnum):
|
71
71
|
TIMEOUT = "timeout"
|
72
|
+
BAD = "bad"
|
72
73
|
UNAUTHORIZED = "unauthorized"
|
73
74
|
FORBIDDEN = "forbidden"
|
74
75
|
NOT_FOUND = "not_found"
|
75
76
|
VALIDATION = "validation"
|
77
|
+
RATE_LIMIT = "rate_limit"
|
76
78
|
INTERNAL = "internal"
|
77
79
|
UNAVAILABLE = "unavailable"
|
78
80
|
|
@@ -91,6 +93,7 @@ class BaseEnums:
|
|
91
93
|
SERVICE = "service"
|
92
94
|
|
93
95
|
class OperationLayer(StrEnum):
|
96
|
+
MIDDLEWARE = "middleware"
|
94
97
|
ROUTER = "router"
|
95
98
|
CONTROLLER = "controller"
|
96
99
|
SERVICE = "service"
|
@@ -122,6 +125,7 @@ class BaseEnums:
|
|
122
125
|
READ = "read"
|
123
126
|
UPDATE = "update"
|
124
127
|
DELETE = "delete"
|
128
|
+
OTHER = "other"
|
125
129
|
|
126
130
|
class CreateType(StrEnum):
|
127
131
|
CREATE = "create"
|
@@ -185,12 +189,14 @@ class BaseEnums:
|
|
185
189
|
APPLICATION = "application"
|
186
190
|
CACHE = "cache"
|
187
191
|
CLIENT = "client"
|
192
|
+
CONTROLLER = "controller"
|
188
193
|
DATABASE = "database"
|
189
194
|
MIDDLEWARE = "middleware"
|
190
195
|
REPOSITORY = "repository"
|
196
|
+
ROUTER = "router"
|
191
197
|
SERVICE = "service"
|
192
198
|
|
193
|
-
class
|
199
|
+
class LogLevel(IntEnum):
|
194
200
|
CRITICAL = logging.CRITICAL
|
195
201
|
FATAL = logging.FATAL
|
196
202
|
ERROR = logging.ERROR
|
@@ -4,6 +4,7 @@ from maleo_foundation.models.schemas import BaseGeneralSchemas
|
|
4
4
|
from maleo_foundation.models.transfers.general.configurations.middleware import (
|
5
5
|
MiddlewareConfigurations,
|
6
6
|
)
|
7
|
+
from maleo_foundation.models.transfers.general.settings import Settings
|
7
8
|
from maleo_foundation.middlewares.authentication import add_authentication_middleware
|
8
9
|
from maleo_foundation.middlewares.base import add_base_middleware
|
9
10
|
from maleo_foundation.middlewares.cors import add_cors_middleware
|
@@ -14,12 +15,14 @@ class MiddlewareManager:
|
|
14
15
|
def __init__(
|
15
16
|
self,
|
16
17
|
app: FastAPI,
|
18
|
+
settings: Settings,
|
17
19
|
configurations: MiddlewareConfigurations,
|
18
20
|
keys: BaseGeneralSchemas.RSAKeys,
|
19
21
|
logger: MiddlewareLogger,
|
20
22
|
maleo_foundation: MaleoFoundationClientManager,
|
21
23
|
):
|
22
24
|
self._app = app
|
25
|
+
self._settings = settings
|
23
26
|
self._configurations = configurations
|
24
27
|
self._keys = keys
|
25
28
|
self._logger = logger
|
@@ -33,23 +36,20 @@ class MiddlewareManager:
|
|
33
36
|
def add_cors(self) -> None:
|
34
37
|
add_cors_middleware(
|
35
38
|
app=self._app,
|
36
|
-
allow_origins=self._configurations.
|
37
|
-
allow_methods=self._configurations.
|
38
|
-
allow_headers=self._configurations.
|
39
|
-
allow_credentials=self._configurations.
|
39
|
+
allow_origins=self._configurations.cors.allow_origins,
|
40
|
+
allow_methods=self._configurations.cors.allow_methods,
|
41
|
+
allow_headers=self._configurations.cors.allow_headers,
|
42
|
+
allow_credentials=self._configurations.cors.allow_credentials,
|
40
43
|
expose_headers=self._configurations.cors.expose_headers,
|
41
44
|
)
|
42
45
|
|
43
46
|
def add_base(self):
|
44
47
|
add_base_middleware(
|
45
48
|
app=self._app,
|
49
|
+
settings=self._settings,
|
46
50
|
keys=self._keys,
|
47
51
|
logger=self._logger,
|
48
52
|
maleo_foundation=self._maleo_foundation,
|
49
|
-
allow_origins=self._configurations.general.allow_origins,
|
50
|
-
allow_methods=self._configurations.general.allow_methods,
|
51
|
-
allow_headers=self._configurations.general.allow_headers,
|
52
|
-
allow_credentials=self._configurations.general.allow_credentials,
|
53
53
|
limit=self._configurations.base.limit,
|
54
54
|
window=self._configurations.base.window,
|
55
55
|
cleanup_interval=self._configurations.base.cleanup_interval,
|
@@ -40,6 +40,7 @@ from maleo_foundation.utils.logging import (
|
|
40
40
|
DatabaseLogger,
|
41
41
|
MiddlewareLogger,
|
42
42
|
RepositoryLogger,
|
43
|
+
RouterLogger,
|
43
44
|
ServiceLogger,
|
44
45
|
)
|
45
46
|
from .credential import CredentialManager
|
@@ -60,10 +61,6 @@ class ServiceManager:
|
|
60
61
|
self._log_config = log_config # * Declare log config
|
61
62
|
self._settings = settings # * Initialize settings
|
62
63
|
|
63
|
-
# * Disable google cloud logging if environment is local
|
64
|
-
if self._settings.ENVIRONMENT == "local":
|
65
|
-
self._log_config.google_cloud_logging = None
|
66
|
-
|
67
64
|
# * Initialize Credential Manager
|
68
65
|
self._credential_manager = CredentialManager(
|
69
66
|
settings=self._settings, log_config=self._log_config
|
@@ -156,6 +153,11 @@ class ServiceManager:
|
|
156
153
|
service_key=self.settings.SERVICE_KEY,
|
157
154
|
**self._log_config.model_dump(),
|
158
155
|
)
|
156
|
+
router = RouterLogger(
|
157
|
+
environment=self.settings.ENVIRONMENT,
|
158
|
+
service_key=self.settings.SERVICE_KEY,
|
159
|
+
**self._log_config.model_dump(),
|
160
|
+
)
|
159
161
|
service = ServiceLogger(
|
160
162
|
environment=self.settings.ENVIRONMENT,
|
161
163
|
service_key=self.settings.SERVICE_KEY,
|
@@ -167,6 +169,7 @@ class ServiceManager:
|
|
167
169
|
database=database,
|
168
170
|
middleware=middleware,
|
169
171
|
repository=repository,
|
172
|
+
router=router,
|
170
173
|
service=service,
|
171
174
|
)
|
172
175
|
|
@@ -306,6 +309,7 @@ class ServiceManager:
|
|
306
309
|
self._loggers.application.info("Configuring middlewares")
|
307
310
|
self._middleware = MiddlewareManager(
|
308
311
|
app=self._app,
|
312
|
+
settings=self._settings,
|
309
313
|
configurations=self.configurations.middleware,
|
310
314
|
keys=self._keys,
|
311
315
|
logger=self._loggers.middleware,
|
{maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/middlewares/authentication.py
RENAMED
@@ -3,10 +3,11 @@ from starlette.authentication import AuthenticationBackend, AuthenticationError
|
|
3
3
|
from starlette.middleware.authentication import AuthenticationMiddleware
|
4
4
|
from starlette.requests import HTTPConnection
|
5
5
|
from typing import Tuple
|
6
|
-
from maleo_foundation.authentication import
|
6
|
+
from maleo_foundation.authentication import Credentials, User
|
7
7
|
from maleo_foundation.enums import BaseEnums
|
8
8
|
from maleo_foundation.client.manager import MaleoFoundationClientManager
|
9
9
|
from maleo_foundation.models.schemas import BaseGeneralSchemas
|
10
|
+
from maleo_foundation.models.transfers.general.authentication import Token
|
10
11
|
from maleo_foundation.models.transfers.parameters.token import (
|
11
12
|
MaleoFoundationTokenParametersTransfers,
|
12
13
|
)
|
@@ -67,7 +68,7 @@ class Backend(AuthenticationBackend):
|
|
67
68
|
User(authenticated=True, username=payload.u_u, email=payload.u_e),
|
68
69
|
)
|
69
70
|
|
70
|
-
return Credentials(), User(
|
71
|
+
return Credentials(), User()
|
71
72
|
|
72
73
|
|
73
74
|
def add_authentication_middleware(
|