nlbone 0.7.0__py3-none-any.whl → 0.7.2__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/config/settings.py +5 -5
- nlbone/interfaces/api/dependencies/auth.py +10 -0
- {nlbone-0.7.0.dist-info → nlbone-0.7.2.dist-info}/METADATA +1 -1
- {nlbone-0.7.0.dist-info → nlbone-0.7.2.dist-info}/RECORD +7 -7
- {nlbone-0.7.0.dist-info → nlbone-0.7.2.dist-info}/WHEEL +0 -0
- {nlbone-0.7.0.dist-info → nlbone-0.7.2.dist-info}/entry_points.txt +0 -0
- {nlbone-0.7.0.dist-info → nlbone-0.7.2.dist-info}/licenses/LICENSE +0 -0
nlbone/config/settings.py
CHANGED
|
@@ -26,11 +26,11 @@ def _guess_env_file() -> str | None:
|
|
|
26
26
|
raise Exception("Failed to guess env file path!") from e
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
def
|
|
29
|
+
def read_from_os_env() -> bool:
|
|
30
30
|
raw = os.getenv("NLBONE_ENV") or os.getenv("ENV") or os.getenv("ENVIRONMENT")
|
|
31
31
|
if not raw:
|
|
32
32
|
return False
|
|
33
|
-
return raw.strip().lower()
|
|
33
|
+
return raw.strip().lower() in {"prod", "production", "stage", "staging"}
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
class Settings(BaseSettings):
|
|
@@ -114,9 +114,9 @@ class Settings(BaseSettings):
|
|
|
114
114
|
|
|
115
115
|
@classmethod
|
|
116
116
|
def load(cls, env_file: str | None = None) -> "Settings":
|
|
117
|
-
if
|
|
118
|
-
return cls(
|
|
119
|
-
return cls()
|
|
117
|
+
if read_from_os_env():
|
|
118
|
+
return cls()
|
|
119
|
+
return cls(_env_file=env_file or _guess_env_file())
|
|
120
120
|
|
|
121
121
|
|
|
122
122
|
@lru_cache(maxsize=4)
|
|
@@ -2,9 +2,15 @@ import functools
|
|
|
2
2
|
|
|
3
3
|
from nlbone.adapters.auth import KeycloakAuthService
|
|
4
4
|
from nlbone.adapters.auth.keycloak import get_auth_service
|
|
5
|
+
from nlbone.config.settings import get_settings
|
|
5
6
|
from nlbone.interfaces.api.exceptions import ForbiddenException, UnauthorizedException
|
|
6
7
|
from nlbone.utils.context import current_request
|
|
7
8
|
|
|
9
|
+
@functools.lru_cache()
|
|
10
|
+
def bypass_authz() -> bool:
|
|
11
|
+
if get_settings().ENV != 'prod':
|
|
12
|
+
return True
|
|
13
|
+
return False
|
|
8
14
|
|
|
9
15
|
def current_user_id() -> int:
|
|
10
16
|
user_id = current_request().state.user_id
|
|
@@ -50,6 +56,8 @@ def user_authenticated(func):
|
|
|
50
56
|
|
|
51
57
|
|
|
52
58
|
def user_has_access_func(*, permissions=None):
|
|
59
|
+
if bypass_authz():
|
|
60
|
+
return
|
|
53
61
|
request = current_request()
|
|
54
62
|
if not current_user_id():
|
|
55
63
|
raise UnauthorizedException()
|
|
@@ -73,6 +81,8 @@ def has_access(*, permissions=None):
|
|
|
73
81
|
|
|
74
82
|
|
|
75
83
|
def client_or_user_has_access_func(permissions=None, client_permissions=None):
|
|
84
|
+
if bypass_authz():
|
|
85
|
+
return
|
|
76
86
|
request = current_request()
|
|
77
87
|
token = getattr(request.state, "token", None)
|
|
78
88
|
if not token:
|
|
@@ -40,7 +40,7 @@ nlbone/adapters/ticketing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
|
40
40
|
nlbone/adapters/ticketing/client.py,sha256=V5_u7cxV67eAG4jj4vUD23VWGiMXIXSAU362pNS6hYU,1289
|
|
41
41
|
nlbone/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
42
42
|
nlbone/config/logging.py,sha256=Ot6Ctf7EQZlW8YNB-uBdleqI6wixn5fH0Eo6QRgNkQk,4358
|
|
43
|
-
nlbone/config/settings.py,sha256=
|
|
43
|
+
nlbone/config/settings.py,sha256=E67FOUgPH9prp5WQzGtOIDbVe0DTr_3WziBIh27SEvM,4324
|
|
44
44
|
nlbone/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
45
45
|
nlbone/core/application/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
46
46
|
nlbone/core/application/base_worker.py,sha256=5brIToSd-vi6tw0ukhHnUZGZhOLq1SQ-NRRy-kp6D24,1193
|
|
@@ -74,7 +74,7 @@ nlbone/interfaces/api/additional_filed/default_field_rules/__init__.py,sha256=LU
|
|
|
74
74
|
nlbone/interfaces/api/additional_filed/default_field_rules/image_field_rules.py,sha256=ecKqPeXZ-YiF14RK9PmK7ln3PCzpCUc18S5zm5IF3fw,339
|
|
75
75
|
nlbone/interfaces/api/dependencies/__init__.py,sha256=rnYRrFVZCfICQrp_PVFlzNg3BeC57yM08wn2DbOHCfk,359
|
|
76
76
|
nlbone/interfaces/api/dependencies/async_auth.py,sha256=bfxgBXhp29WqevjTG4jrdPNR-75APm4jKyHdOOtxnp4,1825
|
|
77
|
-
nlbone/interfaces/api/dependencies/auth.py,sha256=
|
|
77
|
+
nlbone/interfaces/api/dependencies/auth.py,sha256=dKq3TIJN4CqKZcRIlMV3rz3v8sFgh9Rz_slIP2VNcvs,3083
|
|
78
78
|
nlbone/interfaces/api/dependencies/db.py,sha256=-UD39J_86UU7ZJs2ZncpdND0yhAG0NeeeALrgSDuuFw,466
|
|
79
79
|
nlbone/interfaces/api/dependencies/uow.py,sha256=QfLEvLYLNWZJQN1k-0q0hBVtUld3D75P4j39q_RjcnE,1181
|
|
80
80
|
nlbone/interfaces/api/middleware/__init__.py,sha256=zbX2vaEAfxRMIYwO2MVY_2O6bqG5H9o7HqGpX14U3Is,158
|
|
@@ -104,8 +104,8 @@ nlbone/utils/http.py,sha256=UXUoXgQdTRNT08ho8zl-C5ekfDsD8uf-JiMQ323ooqw,872
|
|
|
104
104
|
nlbone/utils/normalize_mobile.py,sha256=sGH4tV9gX-6eVKozviNWJhm1DN1J28Nj-ERldCYkS_E,732
|
|
105
105
|
nlbone/utils/redactor.py,sha256=-V4HrHmHwPi3Kez587Ek1uJlgK35qGSrwBOvcbw8Jas,1279
|
|
106
106
|
nlbone/utils/time.py,sha256=DjjyQ9GLsfXoT6NK8RDW2rOlJg3e6sF04Jw6PBUrSvg,1268
|
|
107
|
-
nlbone-0.7.
|
|
108
|
-
nlbone-0.7.
|
|
109
|
-
nlbone-0.7.
|
|
110
|
-
nlbone-0.7.
|
|
111
|
-
nlbone-0.7.
|
|
107
|
+
nlbone-0.7.2.dist-info/METADATA,sha256=KqXtF5AV-X4TaqT1Gouy9CUMa0JZAy0R2fq5a6zeBeA,2294
|
|
108
|
+
nlbone-0.7.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
109
|
+
nlbone-0.7.2.dist-info/entry_points.txt,sha256=CpIL45t5nbhl1dGQPhfIIDfqqak3teK0SxPGBBr7YCk,59
|
|
110
|
+
nlbone-0.7.2.dist-info/licenses/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
111
|
+
nlbone-0.7.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|