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.
Files changed (161) hide show
  1. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/PKG-INFO +3 -1
  2. maleo_foundation-0.3.74/maleo_foundation/authentication.py +36 -0
  3. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/constants.py +2 -0
  4. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/enums.py +7 -1
  5. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/middleware.py +8 -8
  6. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/service.py +8 -4
  7. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/middlewares/authentication.py +3 -2
  8. maleo_foundation-0.3.74/maleo_foundation/middlewares/base.py +589 -0
  9. maleo_foundation-0.3.74/maleo_foundation/models/schemas/general.py +116 -0
  10. maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/authentication.py +35 -0
  11. {maleo_foundation-0.3.72/maleo_foundation → maleo_foundation-0.3.74/maleo_foundation/models/transfers/general}/authorization.py +0 -3
  12. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/__init__.py +2 -0
  13. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/middleware.py +6 -7
  14. maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/operation.py +213 -0
  15. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/request.py +13 -19
  16. maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/response.py +14 -0
  17. maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/service.py +9 -0
  18. maleo_foundation-0.3.74/maleo_foundation/models/transfers/general/user_agent.py +34 -0
  19. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/exceptions/client.py +22 -23
  20. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/exceptions/service.py +21 -22
  21. maleo_foundation-0.3.74/maleo_foundation/utils/extractor.py +97 -0
  22. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/logging.py +40 -0
  23. maleo_foundation-0.3.74/maleo_foundation/utils/parser.py +7 -0
  24. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/PKG-INFO +3 -1
  25. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/SOURCES.txt +6 -4
  26. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/requires.txt +2 -0
  27. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/pyproject.toml +3 -1
  28. maleo_foundation-0.3.72/maleo_foundation/authentication.py +0 -82
  29. maleo_foundation-0.3.72/maleo_foundation/middlewares/base.py +0 -474
  30. maleo_foundation-0.3.72/maleo_foundation/models/schemas/general.py +0 -242
  31. maleo_foundation-0.3.72/maleo_foundation/models/transfers/general/operation.py +0 -51
  32. maleo_foundation-0.3.72/maleo_foundation/utils/dependencies/__init__.py +0 -6
  33. maleo_foundation-0.3.72/maleo_foundation/utils/dependencies/auth.py +0 -17
  34. maleo_foundation-0.3.72/maleo_foundation/utils/dependencies/context.py +0 -8
  35. maleo_foundation-0.3.72/maleo_foundation/utils/extractor.py +0 -67
  36. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/README.md +0 -0
  37. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/__init__.py +0 -0
  38. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/__init__.py +0 -0
  39. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/manager.py +0 -0
  40. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/__init__.py +0 -0
  41. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/encryption/__init__.py +0 -0
  42. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/encryption/aes.py +0 -0
  43. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/encryption/rsa.py +0 -0
  44. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/hash/__init__.py +0 -0
  45. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/hash/bcrypt.py +0 -0
  46. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/hash/hmac.py +0 -0
  47. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/hash/sha256.py +0 -0
  48. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/key.py +0 -0
  49. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/signature.py +0 -0
  50. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/client/services/token.py +0 -0
  51. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/controller_types.py +0 -0
  52. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/__init__.py +0 -0
  53. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/client.py +0 -0
  54. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/encryption/__init__.py +0 -0
  55. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/encryption/aes.py +0 -0
  56. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/encryption/rsa.py +0 -0
  57. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/general.py +0 -0
  58. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/hash.py +0 -0
  59. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/key.py +0 -0
  60. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/service.py +0 -0
  61. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/signature.py +0 -0
  62. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/expanded_types/token.py +0 -0
  63. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/extended_types.py +0 -0
  64. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/__init__.py +0 -0
  65. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/cache.py +0 -0
  66. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/__init__.py +0 -0
  67. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/base.py +0 -0
  68. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/__init__.py +0 -0
  69. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/base.py +0 -0
  70. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/parameter.py +0 -0
  71. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/secret.py +0 -0
  72. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/storage.py +0 -0
  73. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/google/subscription.py +0 -0
  74. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/client/maleo.py +0 -0
  75. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/configuration.py +0 -0
  76. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/credential.py +0 -0
  77. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/managers/db.py +0 -0
  78. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/middlewares/cors.py +0 -0
  79. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/__init__.py +0 -0
  80. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/responses.py +0 -0
  81. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/__init__.py +0 -0
  82. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/encryption.py +0 -0
  83. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/hash.py +0 -0
  84. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/key.py +0 -0
  85. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/parameter.py +0 -0
  86. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/result.py +0 -0
  87. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/signature.py +0 -0
  88. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/schemas/token.py +0 -0
  89. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/table.py +0 -0
  90. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/__init__.py +0 -0
  91. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/__init__.py +0 -0
  92. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/cache/__init__.py +0 -0
  93. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/cache/redis.py +0 -0
  94. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/client/__init__.py +0 -0
  95. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/client/maleo.py +0 -0
  96. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/database.py +0 -0
  97. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/pubsub/__init__.py +0 -0
  98. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/pubsub/publisher.py +0 -0
  99. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/pubsub/subscription.py +0 -0
  100. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/configurations/service.py +0 -0
  101. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/credentials.py +0 -0
  102. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/data.py +0 -0
  103. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/database.py +0 -0
  104. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/key.py +0 -0
  105. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/settings.py +0 -0
  106. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/signature.py +0 -0
  107. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/general/token.py +0 -0
  108. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/__init__.py +0 -0
  109. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/client.py +0 -0
  110. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/encryption/__init__.py +0 -0
  111. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/encryption/aes.py +0 -0
  112. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/encryption/rsa.py +0 -0
  113. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/general.py +0 -0
  114. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/hash/__init__.py +0 -0
  115. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/hash/bcrypt.py +0 -0
  116. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/hash/hmac.py +0 -0
  117. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/hash/sha256.py +0 -0
  118. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/key.py +0 -0
  119. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/service.py +0 -0
  120. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/signature.py +0 -0
  121. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/parameters/token.py +0 -0
  122. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/__init__.py +0 -0
  123. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/client/__init__.py +0 -0
  124. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/client/controllers/__init__.py +0 -0
  125. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/client/controllers/http.py +0 -0
  126. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/client/service.py +0 -0
  127. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/encryption/__init__.py +0 -0
  128. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/encryption/aes.py +0 -0
  129. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/encryption/rsa.py +0 -0
  130. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/hash.py +0 -0
  131. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/key.py +0 -0
  132. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/service/__init__.py +0 -0
  133. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/service/controllers/__init__.py +0 -0
  134. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/service/controllers/rest.py +0 -0
  135. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/service/general.py +0 -0
  136. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/signature.py +0 -0
  137. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/models/transfers/results/token.py +0 -0
  138. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/rest_controller_result.py +0 -0
  139. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/types.py +0 -0
  140. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/__init__.py +0 -0
  141. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/cache.py +0 -0
  142. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/client.py +0 -0
  143. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/controller.py +0 -0
  144. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/exceptions/__init__.py +0 -0
  145. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/exceptions/request.py +0 -0
  146. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/formatter/__init__.py +0 -0
  147. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/formatter/case.py +0 -0
  148. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/__init__.py +0 -0
  149. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/credential/__init__.py +0 -0
  150. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/credential/google.py +0 -0
  151. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/json.py +0 -0
  152. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/key/__init__.py +0 -0
  153. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/key/rsa.py +0 -0
  154. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/loaders/yaml.py +0 -0
  155. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/merger.py +0 -0
  156. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/query.py +0 -0
  157. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/repository.py +0 -0
  158. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation/utils/searcher.py +0 -0
  159. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/dependency_links.txt +0 -0
  160. {maleo_foundation-0.3.72 → maleo_foundation-0.3.74}/maleo_foundation.egg-info/top_level.txt +0 -0
  161. {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.72
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 LoggerLevel(IntEnum):
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.general.allow_origins,
37
- allow_methods=self._configurations.general.allow_methods,
38
- allow_headers=self._configurations.general.allow_headers,
39
- allow_credentials=self._configurations.general.allow_credentials,
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,
@@ -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 Token, Credentials, User
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(authenticated=False)
71
+ return Credentials(), User()
71
72
 
72
73
 
73
74
  def add_authentication_middleware(