maleo-foundation 0.1.68__tar.gz → 0.1.69__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 (85) hide show
  1. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/PKG-INFO +1 -1
  2. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/middlewares/authentication.py +0 -6
  3. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/responses.py +2 -1
  4. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/exceptions.py +3 -5
  5. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation.egg-info/PKG-INFO +1 -1
  6. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/pyproject.toml +1 -1
  7. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/README.md +0 -0
  8. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/__init__.py +0 -0
  9. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/authentication.py +0 -0
  10. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/client/__init__.py +0 -0
  11. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/client/manager.py +0 -0
  12. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/client/services/__init__.py +0 -0
  13. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/client/services/signature.py +0 -0
  14. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/client/services/token.py +0 -0
  15. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/constants.py +0 -0
  16. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/enums.py +0 -0
  17. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/expanded_types/__init__.py +0 -0
  18. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/expanded_types/client.py +0 -0
  19. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/expanded_types/general.py +0 -0
  20. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/expanded_types/query.py +0 -0
  21. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/expanded_types/service.py +0 -0
  22. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/expanded_types/signature.py +0 -0
  23. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/expanded_types/token.py +0 -0
  24. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/extended_types.py +0 -0
  25. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/managers/__init__.py +0 -0
  26. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/managers/client/__init__.py +0 -0
  27. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/managers/client/base.py +0 -0
  28. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/managers/client/google/__init__.py +0 -0
  29. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/managers/client/google/base.py +0 -0
  30. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/managers/client/google/secret.py +0 -0
  31. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/managers/client/google/storage.py +0 -0
  32. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/managers/client/maleo.py +0 -0
  33. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/managers/db.py +0 -0
  34. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/managers/middleware.py +0 -0
  35. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/managers/service.py +0 -0
  36. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/middlewares/base.py +0 -0
  37. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/middlewares/cors.py +0 -0
  38. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/__init__.py +0 -0
  39. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/schemas/__init__.py +0 -0
  40. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/schemas/general.py +0 -0
  41. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/schemas/parameter.py +0 -0
  42. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/schemas/result.py +0 -0
  43. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/schemas/signature.py +0 -0
  44. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/schemas/token.py +0 -0
  45. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/table.py +0 -0
  46. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/__init__.py +0 -0
  47. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/general/__init__.py +0 -0
  48. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/general/signature.py +0 -0
  49. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/general/token.py +0 -0
  50. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/parameters/__init__.py +0 -0
  51. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/parameters/client.py +0 -0
  52. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/parameters/general.py +0 -0
  53. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/parameters/service.py +0 -0
  54. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/parameters/signature.py +0 -0
  55. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/parameters/token.py +0 -0
  56. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/results/__init__.py +0 -0
  57. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/results/client/__init__.py +0 -0
  58. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/results/client/controllers/__init__.py +0 -0
  59. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/results/client/controllers/http.py +0 -0
  60. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/results/client/service.py +0 -0
  61. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/results/service/__init__.py +0 -0
  62. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/results/service/controllers/__init__.py +0 -0
  63. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/results/service/controllers/rest.py +0 -0
  64. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/results/service/general.py +0 -0
  65. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/results/service/query.py +0 -0
  66. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/results/signature.py +0 -0
  67. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/models/transfers/results/token.py +0 -0
  68. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/types.py +0 -0
  69. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/__init__.py +0 -0
  70. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/controller.py +0 -0
  71. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/extractor.py +0 -0
  72. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/formatter/__init__.py +0 -0
  73. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/formatter/case.py +0 -0
  74. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/loaders/__init__.py +0 -0
  75. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/loaders/json.py +0 -0
  76. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/loaders/key.py +0 -0
  77. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/loaders/yaml.py +0 -0
  78. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/logging.py +0 -0
  79. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/mergers.py +0 -0
  80. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation/utils/query.py +0 -0
  81. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation.egg-info/SOURCES.txt +0 -0
  82. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation.egg-info/dependency_links.txt +0 -0
  83. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation.egg-info/requires.txt +0 -0
  84. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/maleo_foundation.egg-info/top_level.txt +0 -0
  85. {maleo_foundation-0.1.68 → maleo_foundation-0.1.69}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.1.68
3
+ Version: 0.1.69
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -9,7 +9,6 @@ from maleo_foundation.client.manager import MaleoFoundationClientManager
9
9
  from maleo_foundation.models.schemas import BaseGeneralSchemas
10
10
  from maleo_foundation.models.transfers.parameters.token import BaseTokenParametersTransfers
11
11
  from maleo_foundation.utils.exceptions import BaseExceptions
12
- from maleo_foundation.utils.extractor import BaseExtractors
13
12
  from maleo_foundation.utils.logging import MiddlewareLogger
14
13
 
15
14
  class Backend(AuthenticationBackend):
@@ -20,26 +19,21 @@ class Backend(AuthenticationBackend):
20
19
  self._maleo_foundation = maleo_foundation
21
20
 
22
21
  async def authenticate(self, conn:HTTPConnection) -> Tuple[Credentials, User]:
23
- client_ip = BaseExtractors.extract_client_ip(conn)
24
22
  if "Authorization" not in conn.headers:
25
- self._logger.info(f"Request | IP: {client_ip} | URL: {conn.url.path} - Result | General: Header did not contain authorization")
26
23
  return Credentials(), User(authenticated=False)
27
24
 
28
25
  auth = conn.headers["Authorization"]
29
26
  scheme, token = auth.split()
30
27
  if scheme != 'Bearer':
31
- self._logger.info(f"Request | IP: {client_ip} | URL: {conn.url.path} - Result | General: Authorization scheme is not Bearer")
32
28
  raise AuthenticationError("Authorization scheme must be Bearer token")
33
29
 
34
30
  decode_token_parameters = BaseTokenParametersTransfers.Decode(key=self._keys.public, token=token)
35
31
  decode_token_result = self._maleo_foundation.services.token.decode(parameters=decode_token_parameters)
36
32
  if not decode_token_result.success:
37
- self._logger.error(f"Request | IP: {client_ip} | URL: {conn.url.path} - Result | General: Failed decoding authorization token")
38
33
  raise AuthenticationError("Invalid Bearer token, unable to decode token")
39
34
  if decode_token_result.data.exp_dt <= datetime.now(tz=timezone.utc):
40
35
  raise AuthenticationError("Expired Bearer token, request new or refresh token")
41
36
 
42
- self._logger.info(f"Request | IP: {client_ip} | URL: {conn.url.path} - Result | Username: {decode_token_result.data.u_u} | Email: {decode_token_result.data.u_e}")
43
37
  return Credentials(token=token, payload=decode_token_result.data, scopes=["authenticated"]), User(authenticated=True, username=decode_token_result.data.u_u, email=decode_token_result.data.u_e)
44
38
 
45
39
  def add_authentication_middleware(app:FastAPI, keys:BaseGeneralSchemas.RSAKeys, logger:MiddlewareLogger, maleo_foundation:MaleoFoundationClientManager) -> None:
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
  from fastapi import status
3
3
  from pydantic import Field, model_validator
4
+ from typing import Dict, Type, Union
4
5
  from maleo_foundation.models.schemas.general import BaseGeneralSchemas
5
6
  from maleo_foundation.models.schemas.result import BaseResultSchemas
6
7
  from maleo_foundation.types import BaseTypes
@@ -88,7 +89,7 @@ class BaseResponses:
88
89
  return values
89
90
 
90
91
  #* ----- ----- Responses Class ----- ----- *#
91
- other_responses={
92
+ other_responses:Dict[int, Dict[str, Union[str, Type[Fail]]]]={
92
93
  status.HTTP_400_BAD_REQUEST: {
93
94
  "description": "Bad Request Response",
94
95
  "model": BadRequest
@@ -21,11 +21,9 @@ class BaseExceptions:
21
21
 
22
22
  @staticmethod
23
23
  async def http_exception_handler(request:Request, exc:StarletteHTTPException):
24
- if exc.status_code == 404:
25
- return JSONResponse(content=BaseResponses.NotFound().model_dump(), status_code=status.HTTP_404_NOT_FOUND)
26
-
27
- #* Handle other HTTP exceptions normally
28
- return None
24
+ if exc.status_code in BaseResponses.other_responses:
25
+ return JSONResponse(content=BaseResponses.other_responses[exc.status_code]["model"]().model_dump(), status_code=exc.status_code)
26
+ return JSONResponse(content=BaseResponses.ServerError().model_dump(), status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
29
27
 
30
28
  @staticmethod
31
29
  def database_exception_handler(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.1.68
3
+ Version: 0.1.69
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "maleo_foundation"
7
- version = "0.1.68"
7
+ version = "0.1.69"
8
8
  description = "Foundation package for Maleo"
9
9
  authors = [
10
10
  { name = "Agra Bima Yuda", email = "agra@nexmedis.com" }