nlbone 0.7.3__py3-none-any.whl → 0.7.8__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.
- nlbone/core/domain/base.py +8 -1
- nlbone/interfaces/api/dependencies/async_auth.py +2 -4
- nlbone/utils/http.py +7 -1
- {nlbone-0.7.3.dist-info → nlbone-0.7.8.dist-info}/METADATA +1 -1
- {nlbone-0.7.3.dist-info → nlbone-0.7.8.dist-info}/RECORD +8 -8
- {nlbone-0.7.3.dist-info → nlbone-0.7.8.dist-info}/WHEEL +0 -0
- {nlbone-0.7.3.dist-info → nlbone-0.7.8.dist-info}/entry_points.txt +0 -0
- {nlbone-0.7.3.dist-info → nlbone-0.7.8.dist-info}/licenses/LICENSE +0 -0
nlbone/core/domain/base.py
CHANGED
|
@@ -18,7 +18,7 @@ class DomainError(Exception):
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
class Message
|
|
21
|
+
class Message:
|
|
22
22
|
pass
|
|
23
23
|
|
|
24
24
|
|
|
@@ -33,6 +33,13 @@ class DomainEvent(Message):
|
|
|
33
33
|
def name(self):
|
|
34
34
|
return self.__class__.__name__
|
|
35
35
|
|
|
36
|
+
def model_dump(self):
|
|
37
|
+
d = self.__dict__
|
|
38
|
+
for k, v in d.items():
|
|
39
|
+
if isinstance(v, BaseId):
|
|
40
|
+
d[k] = v.value
|
|
41
|
+
return d
|
|
42
|
+
|
|
36
43
|
|
|
37
44
|
@dataclass(frozen=True)
|
|
38
45
|
class Command:
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import functools
|
|
2
2
|
|
|
3
|
+
from .auth import client_has_access_func
|
|
3
4
|
from nlbone.adapters.auth import KeycloakAuthService
|
|
4
5
|
from nlbone.interfaces.api.exceptions import ForbiddenException, UnauthorizedException
|
|
5
6
|
from nlbone.utils.context import current_request
|
|
@@ -23,10 +24,7 @@ def client_has_access(*, permissions=None):
|
|
|
23
24
|
def decorator(func):
|
|
24
25
|
@functools.wraps(func)
|
|
25
26
|
async def wrapper(*args, **kwargs):
|
|
26
|
-
|
|
27
|
-
if not KeycloakAuthService().client_has_access(request.state.token, permissions=permissions):
|
|
28
|
-
raise ForbiddenException(f"Forbidden {permissions}")
|
|
29
|
-
|
|
27
|
+
client_has_access_func(permissions=permissions)
|
|
30
28
|
return await func(*args, **kwargs)
|
|
31
29
|
|
|
32
30
|
return wrapper
|
nlbone/utils/http.py
CHANGED
|
@@ -4,13 +4,15 @@ import json
|
|
|
4
4
|
from typing import Any
|
|
5
5
|
from urllib.parse import urlparse, urlunparse
|
|
6
6
|
|
|
7
|
+
from nlbone.utils.context import current_request
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
def auth_headers(token: str | None) -> dict[str, str]:
|
|
9
11
|
return {"Authorization": f"Bearer {token}"} if token else {}
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
def build_list_query(
|
|
13
|
-
|
|
15
|
+
limit: int, offset: int, filters: dict[str, Any] | None, sort: list[tuple[str, str]] | None
|
|
14
16
|
) -> dict[str, Any]:
|
|
15
17
|
q: dict[str, Any] = {"limit": limit, "offset": offset}
|
|
16
18
|
if filters:
|
|
@@ -27,3 +29,7 @@ def normalize_https_base(url: str, enforce_https: bool = True) -> str:
|
|
|
27
29
|
if p.path.endswith("/"):
|
|
28
30
|
p = p._replace(path=p.path.rstrip("/"))
|
|
29
31
|
return str(urlunparse(p))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def get_service_base_url() -> str:
|
|
35
|
+
return current_request().base_url
|
|
@@ -53,7 +53,7 @@ nlbone/core/application/registry.py,sha256=dTqV_4bkMsLJ60CesZuEel5xO36cD1qikiaCL
|
|
|
53
53
|
nlbone/core/application/use_case.py,sha256=3GMQZ3CFK5cbLoBNBgohPft6GBq2j9_wr8iKRq_osQA,247
|
|
54
54
|
nlbone/core/application/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
55
55
|
nlbone/core/domain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
56
|
-
nlbone/core/domain/base.py,sha256=
|
|
56
|
+
nlbone/core/domain/base.py,sha256=9OCjYRBmDFnHpLdfkA3HuxalL0kJ00xU9HgpNHbeENY,2468
|
|
57
57
|
nlbone/core/domain/models.py,sha256=VEIfzruBXcF5XrDrWEvh9q-Ba9-9x_JG20wZsBF5thc,3270
|
|
58
58
|
nlbone/core/ports/__init__.py,sha256=syJg3fAjQALD5Rjfm9wi9bQpkIvNTWjE9AURBmy587o,132
|
|
59
59
|
nlbone/core/ports/auth.py,sha256=C-GmUqHNx4bAku6KbW_OTpPXCEfurBWWyDi9KxpTi9M,553
|
|
@@ -76,7 +76,7 @@ nlbone/interfaces/api/additional_filed/resolver.py,sha256=jv1TIBBHN4LBIMwHGipcy4
|
|
|
76
76
|
nlbone/interfaces/api/additional_filed/default_field_rules/__init__.py,sha256=LUSAOO3xRUt5ptlraIx7H-7dSkdr1D-WprmnqXRB16g,48
|
|
77
77
|
nlbone/interfaces/api/additional_filed/default_field_rules/image_field_rules.py,sha256=ecKqPeXZ-YiF14RK9PmK7ln3PCzpCUc18S5zm5IF3fw,339
|
|
78
78
|
nlbone/interfaces/api/dependencies/__init__.py,sha256=rnYRrFVZCfICQrp_PVFlzNg3BeC57yM08wn2DbOHCfk,359
|
|
79
|
-
nlbone/interfaces/api/dependencies/async_auth.py,sha256=
|
|
79
|
+
nlbone/interfaces/api/dependencies/async_auth.py,sha256=FBa73JUE2D82k2P1k4daN4IdvZbrbCwREqPJKfYc-4Q,1710
|
|
80
80
|
nlbone/interfaces/api/dependencies/auth.py,sha256=dKq3TIJN4CqKZcRIlMV3rz3v8sFgh9Rz_slIP2VNcvs,3083
|
|
81
81
|
nlbone/interfaces/api/dependencies/db.py,sha256=-UD39J_86UU7ZJs2ZncpdND0yhAG0NeeeALrgSDuuFw,466
|
|
82
82
|
nlbone/interfaces/api/dependencies/uow.py,sha256=QfLEvLYLNWZJQN1k-0q0hBVtUld3D75P4j39q_RjcnE,1181
|
|
@@ -103,12 +103,12 @@ nlbone/utils/cache_keys.py,sha256=Y2YSellHTbUOcoaNbl1jaD4r485VU_e4KXsfBWhYTBo,10
|
|
|
103
103
|
nlbone/utils/cache_registry.py,sha256=w28sEfUQZAhzCCqVH5TflWQY3nyDXyEcFWt8hkuHRHw,823
|
|
104
104
|
nlbone/utils/context.py,sha256=MmclJ24BG2uvSTg1IK7J-Da9BhVFDQ5ag4Ggs2FF1_w,1600
|
|
105
105
|
nlbone/utils/crypto.py,sha256=PX0Tlf2nqXcGbuv16J26MoUPzo2c4xcD4sZBXxhBXgQ,746
|
|
106
|
-
nlbone/utils/http.py,sha256=
|
|
106
|
+
nlbone/utils/http.py,sha256=MPDEyaC16AKsL0YH6sWCPp8NC2TgzEHpWERYK5HcaYQ,1001
|
|
107
107
|
nlbone/utils/normalize_mobile.py,sha256=sGH4tV9gX-6eVKozviNWJhm1DN1J28Nj-ERldCYkS_E,732
|
|
108
108
|
nlbone/utils/redactor.py,sha256=-V4HrHmHwPi3Kez587Ek1uJlgK35qGSrwBOvcbw8Jas,1279
|
|
109
109
|
nlbone/utils/time.py,sha256=DjjyQ9GLsfXoT6NK8RDW2rOlJg3e6sF04Jw6PBUrSvg,1268
|
|
110
|
-
nlbone-0.7.
|
|
111
|
-
nlbone-0.7.
|
|
112
|
-
nlbone-0.7.
|
|
113
|
-
nlbone-0.7.
|
|
114
|
-
nlbone-0.7.
|
|
110
|
+
nlbone-0.7.8.dist-info/METADATA,sha256=pimC_2W3nKm1eBeeEMnZN_XhAdpKIFEeImvDEg7gajY,2294
|
|
111
|
+
nlbone-0.7.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
112
|
+
nlbone-0.7.8.dist-info/entry_points.txt,sha256=CpIL45t5nbhl1dGQPhfIIDfqqak3teK0SxPGBBr7YCk,59
|
|
113
|
+
nlbone-0.7.8.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
114
|
+
nlbone-0.7.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|