maleo-foundation 0.2.38__py3-none-any.whl → 0.2.40__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/authentication.py +6 -14
- maleo_foundation/managers/service.py +6 -0
- maleo_foundation/middlewares/authentication.py +6 -6
- maleo_foundation/models/transfers/general/token.py +7 -3
- {maleo_foundation-0.2.38.dist-info → maleo_foundation-0.2.40.dist-info}/METADATA +1 -1
- {maleo_foundation-0.2.38.dist-info → maleo_foundation-0.2.40.dist-info}/RECORD +8 -8
- {maleo_foundation-0.2.38.dist-info → maleo_foundation-0.2.40.dist-info}/WHEEL +0 -0
- {maleo_foundation-0.2.38.dist-info → maleo_foundation-0.2.40.dist-info}/top_level.txt +0 -0
@@ -5,31 +5,23 @@ from maleo_foundation.enums import BaseEnums
|
|
5
5
|
from maleo_foundation.models.transfers.general.token import MaleoFoundationTokenGeneralTransfers
|
6
6
|
from maleo_foundation.types import BaseTypes
|
7
7
|
|
8
|
+
class Token(BaseModel):
|
9
|
+
type:BaseEnums.TokenType = Field(..., description="Token's type")
|
10
|
+
payload:MaleoFoundationTokenGeneralTransfers.DecodePayload = Field(..., description="Token's payload")
|
11
|
+
|
8
12
|
class Credentials(AuthCredentials):
|
9
13
|
def __init__(
|
10
14
|
self,
|
11
|
-
|
12
|
-
token:BaseTypes.OptionalString = None,
|
13
|
-
payload:Optional[MaleoFoundationTokenGeneralTransfers.DecodePayload] = None,
|
15
|
+
token:Optional[Token] = None,
|
14
16
|
scopes:Optional[Sequence[str]] = None
|
15
17
|
) -> None:
|
16
|
-
self._token_type = token_type
|
17
18
|
self._token = token
|
18
|
-
self._payload = payload
|
19
19
|
super().__init__(scopes)
|
20
20
|
|
21
21
|
@property
|
22
|
-
def
|
23
|
-
return self._token_type
|
24
|
-
|
25
|
-
@property
|
26
|
-
def token(self) -> BaseTypes.OptionalString:
|
22
|
+
def token(self) -> Optional[Token]:
|
27
23
|
return self._token
|
28
24
|
|
29
|
-
@property
|
30
|
-
def payload(self) -> Optional[MaleoFoundationTokenGeneralTransfers.DecodePayload]:
|
31
|
-
return self._payload
|
32
|
-
|
33
25
|
class User(BaseUser):
|
34
26
|
def __init__(
|
35
27
|
self,
|
@@ -9,6 +9,7 @@ from starlette.exceptions import HTTPException
|
|
9
9
|
from starlette.types import Lifespan, AppType
|
10
10
|
from sqlalchemy import MetaData
|
11
11
|
from typing import Optional
|
12
|
+
from uuid import UUID
|
12
13
|
from maleo_foundation.client.manager import MaleoFoundationClientManager
|
13
14
|
from maleo_foundation.enums import BaseEnums
|
14
15
|
from maleo_foundation.models.schemas.general import BaseGeneralSchemas
|
@@ -51,6 +52,7 @@ class Settings(BaseSettings):
|
|
51
52
|
|
52
53
|
class MaleoCredentials(BaseModel):
|
53
54
|
id:int = Field(..., description="ID")
|
55
|
+
uuid:UUID = Field(..., description="UUID")
|
54
56
|
username:str = Field(..., description="Username")
|
55
57
|
email:str = Field(..., description="Email")
|
56
58
|
password:str = Field(..., description="Password")
|
@@ -210,11 +212,13 @@ class ServiceManager:
|
|
210
212
|
else self._settings.ENVIRONMENT
|
211
213
|
)
|
212
214
|
id = int(self._secret_manager.get(f"maleo-service-account-id-{environment}"))
|
215
|
+
uuid = self._secret_manager.get(f"maleo-service-account-uuid-{environment}")
|
213
216
|
email = self._secret_manager.get("maleo-service-account-email")
|
214
217
|
username = self._secret_manager.get("maleo-service-account-username")
|
215
218
|
password = self._secret_manager.get("maleo-service-account-password")
|
216
219
|
self._maleo_credentials = MaleoCredentials(
|
217
220
|
id=id,
|
221
|
+
uuid=UUID(uuid),
|
218
222
|
username=username,
|
219
223
|
email=email,
|
220
224
|
password=password
|
@@ -372,6 +376,8 @@ class ServiceManager:
|
|
372
376
|
iss=None,
|
373
377
|
sub=str(self._maleo_credentials.id),
|
374
378
|
sr="administrator",
|
379
|
+
u_i=self._maleo_credentials.id,
|
380
|
+
u_uu=self._maleo_credentials.uuid,
|
375
381
|
u_u=self._maleo_credentials.username,
|
376
382
|
u_e=self._maleo_credentials.email,
|
377
383
|
u_ut="service",
|
@@ -3,7 +3,7 @@ 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 Credentials, User
|
6
|
+
from maleo_foundation.authentication import Token, 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
|
@@ -33,7 +33,7 @@ class Backend(AuthenticationBackend):
|
|
33
33
|
scheme, token = parts
|
34
34
|
if scheme != 'Bearer':
|
35
35
|
raise AuthenticationError("Authorization scheme must be Bearer token")
|
36
|
-
|
36
|
+
|
37
37
|
#* Decode token
|
38
38
|
decode_token_parameters = (
|
39
39
|
MaleoFoundationTokenParametersTransfers
|
@@ -44,12 +44,12 @@ class Backend(AuthenticationBackend):
|
|
44
44
|
.decode(parameters=decode_token_parameters)
|
45
45
|
)
|
46
46
|
if decode_token_result.success:
|
47
|
+
type = BaseEnums.TokenType.ACCESS
|
47
48
|
payload = decode_token_result.data
|
49
|
+
token = Token(type, payload)
|
48
50
|
return (
|
49
51
|
Credentials(
|
50
|
-
token_type=BaseEnums.TokenType.ACCESS,
|
51
52
|
token=token,
|
52
|
-
payload=payload,
|
53
53
|
scopes=["authenticated", payload.sr]
|
54
54
|
),
|
55
55
|
User(
|
@@ -71,12 +71,12 @@ class Backend(AuthenticationBackend):
|
|
71
71
|
.decode(parameters=decode_token_parameters)
|
72
72
|
)
|
73
73
|
if decode_token_result.success:
|
74
|
+
type = BaseEnums.TokenType.ACCESS
|
74
75
|
payload = decode_token_result.data
|
76
|
+
token = Token(type, payload)
|
75
77
|
return (
|
76
78
|
Credentials(
|
77
|
-
token_type=BaseEnums.TokenType.REFRESH,
|
78
79
|
token=token,
|
79
|
-
payload=payload,
|
80
80
|
scopes=["authenticated", payload.sr]
|
81
81
|
),
|
82
82
|
User(
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from __future__ import annotations
|
2
|
-
from pydantic import BaseModel, Field, model_validator
|
3
2
|
from datetime import datetime, timedelta, timezone
|
3
|
+
from pydantic import BaseModel, Field, model_validator
|
4
|
+
from uuid import UUID
|
4
5
|
from maleo_foundation.types import BaseTypes
|
5
6
|
from maleo_foundation.models.schemas.token import MaleoFoundationTokenSchemas
|
6
7
|
|
@@ -9,10 +10,13 @@ class MaleoFoundationTokenGeneralTransfers:
|
|
9
10
|
iss:BaseTypes.OptionalString = Field(None, description="Token's issuer")
|
10
11
|
sub:BaseTypes.OptionalString = Field(None, description="Token's subject")
|
11
12
|
sr:str = Field(..., description="System role")
|
13
|
+
u_i:str = Field(..., description="user's id")
|
14
|
+
u_uu:UUID = Field(..., description="user's uuid")
|
12
15
|
u_u:str = Field(..., description="user's username")
|
13
16
|
u_e:str = Field(..., description="user's email")
|
14
17
|
u_ut:str = Field(..., description="user's type")
|
15
|
-
o_i:BaseTypes.OptionalInteger = Field(None, description="Organization's
|
18
|
+
o_i:BaseTypes.OptionalInteger = Field(None, description="Organization's id")
|
19
|
+
o_uu:BaseTypes.OptionalUUID = Field(None, description="Organization's uuid")
|
16
20
|
o_k:BaseTypes.OptionalString = Field(None, description="Organization's key")
|
17
21
|
o_ot:BaseTypes.OptionalString = Field(None, description="Organization's type")
|
18
22
|
uor:BaseTypes.OptionalListOfStrings = Field(None, description="User Organization Role")
|
@@ -21,7 +25,7 @@ class MaleoFoundationTokenGeneralTransfers:
|
|
21
25
|
iat_dt:datetime = Field(..., description="Issued at (datetime)")
|
22
26
|
iat:int = Field(..., description="Issued at (integer)")
|
23
27
|
exp_dt:datetime = Field(..., description="Expired at (datetime)")
|
24
|
-
exp:int = Field(..., description="Expired at (
|
28
|
+
exp:int = Field(..., description="Expired at (integer)")
|
25
29
|
|
26
30
|
class BaseEncodePayload(MaleoFoundationTokenSchemas.ExpIn, BasePayload): pass
|
27
31
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
maleo_foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
maleo_foundation/authentication.py,sha256=
|
2
|
+
maleo_foundation/authentication.py,sha256=kmM2QKh0st2p2pac9MKP7yYNpJzI0cFwTOrMtoQ0gMI,1575
|
3
3
|
maleo_foundation/authorization.py,sha256=euq24UEhTaimmM24Ies-kZF1zqVwM_x0Zox_6k7zyqI,281
|
4
4
|
maleo_foundation/constants.py,sha256=aBmEfWlBqZxi0k-n6h2NM1YRLOjMnheEiLyQcjP-zCQ,1164
|
5
5
|
maleo_foundation/enums.py,sha256=OLVgb0rKk2gfG19FEyq9YGrQcmovr_FgtGFUcIu23Lo,3596
|
@@ -34,7 +34,7 @@ maleo_foundation/expanded_types/encryption/rsa.py,sha256=Esf_H8nMz2kOLAWa3M7dlD-
|
|
34
34
|
maleo_foundation/managers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
35
|
maleo_foundation/managers/db.py,sha256=cpY1IOiUytT9XXYtzS0E9OSYOuB7jBKo0XHe__uI1Jg,5340
|
36
36
|
maleo_foundation/managers/middleware.py,sha256=77wRCC_CWc22nSDL-UJanO3rXmSB7wLzaAIXEFjXq6M,4249
|
37
|
-
maleo_foundation/managers/service.py,sha256=
|
37
|
+
maleo_foundation/managers/service.py,sha256=ner08wL3ewUGhTLto7HJMHwXu-YDJoMtMTHDm236Bdc,19265
|
38
38
|
maleo_foundation/managers/cache/__init__.py,sha256=CeY0oof2bVl_v5WS-FKXNwn2gf3xrEMfUsHK9cHo59s,471
|
39
39
|
maleo_foundation/managers/cache/base.py,sha256=YyPjde4KTsp2IHV6NdFMysa0ev-1GX1rtX-0jQPuIBU,837
|
40
40
|
maleo_foundation/managers/cache/redis.py,sha256=xLa8QfXdNtghs0eBxIqc04H3XTYmxLEzrqJZAFCigvM,1150
|
@@ -46,7 +46,7 @@ maleo_foundation/managers/client/google/base.py,sha256=eIdd6C2BFIu4EyZ1j017VZaJn
|
|
46
46
|
maleo_foundation/managers/client/google/parameter.py,sha256=Lnj7mQgxWQpsQwbmDRK5_bF01M1QpM5PS0eZP2q17yQ,1337
|
47
47
|
maleo_foundation/managers/client/google/secret.py,sha256=Ski1CHYeA8vjSk2Oc2Pf4CfFrzT_RcA6NEZwza7gM7Y,4464
|
48
48
|
maleo_foundation/managers/client/google/storage.py,sha256=ECyEBgEvvbTDVfqXey-meGnoU4qvIRU32BxbCuzcaHU,2576
|
49
|
-
maleo_foundation/middlewares/authentication.py,sha256=
|
49
|
+
maleo_foundation/middlewares/authentication.py,sha256=yfM9e0YJqwFrLNkUk8eIJVJ-eyRY6u4c1yrWUmVMJuc,4678
|
50
50
|
maleo_foundation/middlewares/base.py,sha256=8_ENtyB2iKejCOQofESzlAaq_zxDWtHNaq3f10dA020,14554
|
51
51
|
maleo_foundation/middlewares/cors.py,sha256=9uvBvY2N6Vxa9RP_YtESxcWo6Doi6uS0lzAG9iLY7Uc,2288
|
52
52
|
maleo_foundation/models/__init__.py,sha256=AaKehO7c1HyKhoTGRmNHDddSeBXkW-_YNrpOGBu8Ms8,246
|
@@ -65,7 +65,7 @@ maleo_foundation/models/transfers/__init__.py,sha256=oJLJ3Geeme6vBw7R2Dhvdvg4ziV
|
|
65
65
|
maleo_foundation/models/transfers/general/__init__.py,sha256=UPIE9l9XXCb6nWzaV3atMgbbCeBeRzsvFyROJuH2d2w,168
|
66
66
|
maleo_foundation/models/transfers/general/key.py,sha256=tLKkXbwNu7Oc1MdKa8-Y7TlBAIk54h_02AmL5Yg2PrQ,751
|
67
67
|
maleo_foundation/models/transfers/general/signature.py,sha256=J9xQy2HjpCQOnES7RJqsUnDgjFPuakQ1mxyfdTdstSE,297
|
68
|
-
maleo_foundation/models/transfers/general/token.py,sha256=
|
68
|
+
maleo_foundation/models/transfers/general/token.py,sha256=_Uxvo5VE0uP688kW5_aukV_wnwEDhYG-wfhMuElyhOE,2917
|
69
69
|
maleo_foundation/models/transfers/parameters/__init__.py,sha256=oKW4RPIEISISRjsJzD8lsCGY1HhZRTzshPpWHcJu86k,353
|
70
70
|
maleo_foundation/models/transfers/parameters/client.py,sha256=3X1iCThKr72_vds4gdldB0YxTlXoLTF1rGbsXyjyBpg,4051
|
71
71
|
maleo_foundation/models/transfers/parameters/general.py,sha256=WoekZJCIoAllhXdRIJkNRdNq0QEIn0bteiHJLtzkCxU,579
|
@@ -117,7 +117,7 @@ maleo_foundation/utils/loaders/credential/__init__.py,sha256=qopTKvcMVoTFwyRijeg
|
|
117
117
|
maleo_foundation/utils/loaders/credential/google.py,sha256=SKsqPuFnAiCcYLf24CxKnMybhVHpgqnq1gGSlThqjts,994
|
118
118
|
maleo_foundation/utils/loaders/key/__init__.py,sha256=hVygcC2ImHc_aVrSrOmyedR8tMUZokWUKCKOSh5ctbo,106
|
119
119
|
maleo_foundation/utils/loaders/key/rsa.py,sha256=gDhyX6iTFtHiluuhFCozaZ3pOLKU2Y9TlrNMK_GVyGU,3796
|
120
|
-
maleo_foundation-0.2.
|
121
|
-
maleo_foundation-0.2.
|
122
|
-
maleo_foundation-0.2.
|
123
|
-
maleo_foundation-0.2.
|
120
|
+
maleo_foundation-0.2.40.dist-info/METADATA,sha256=pz64jixUYTs4Rd6Av7_ToszZYPEfglgJw9lXXbOzkLk,3598
|
121
|
+
maleo_foundation-0.2.40.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
122
|
+
maleo_foundation-0.2.40.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
|
123
|
+
maleo_foundation-0.2.40.dist-info/RECORD,,
|
File without changes
|
File without changes
|