arpakitlib 1.6.88__py3-none-any.whl → 1.6.90__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.
- arpakitlib/ar_fastapi_util.py +47 -50
- {arpakitlib-1.6.88.dist-info → arpakitlib-1.6.90.dist-info}/METADATA +1 -1
- {arpakitlib-1.6.88.dist-info → arpakitlib-1.6.90.dist-info}/RECORD +7 -7
- {arpakitlib-1.6.88.dist-info → arpakitlib-1.6.90.dist-info}/LICENSE +0 -0
- {arpakitlib-1.6.88.dist-info → arpakitlib-1.6.90.dist-info}/NOTICE +0 -0
- {arpakitlib-1.6.88.dist-info → arpakitlib-1.6.90.dist-info}/WHEEL +0 -0
- {arpakitlib-1.6.88.dist-info → arpakitlib-1.6.90.dist-info}/entry_points.txt +0 -0
arpakitlib/ar_fastapi_util.py
CHANGED
@@ -421,6 +421,9 @@ def get_transmitted_api_data(request: starlette.requests.Request) -> BaseTransmi
|
|
421
421
|
class BaseAPIAuthData(BaseModel):
|
422
422
|
model_config = ConfigDict(extra="forbid", arbitrary_types_allowed=True, from_attributes=True)
|
423
423
|
|
424
|
+
require_api_key_string: bool = False
|
425
|
+
require_token_string: bool = None
|
426
|
+
|
424
427
|
token_string: str | None = None
|
425
428
|
api_key_string: str | None = None
|
426
429
|
|
@@ -428,7 +431,7 @@ class BaseAPIAuthData(BaseModel):
|
|
428
431
|
def base_api_auth(
|
429
432
|
*,
|
430
433
|
require_api_key_string: bool = False,
|
431
|
-
require_token_string: bool = False
|
434
|
+
require_token_string: bool = False
|
432
435
|
) -> Callable:
|
433
436
|
async def func(
|
434
437
|
*,
|
@@ -439,79 +442,73 @@ def base_api_auth(
|
|
439
442
|
request: fastapi.Request
|
440
443
|
) -> BaseAPIAuthData:
|
441
444
|
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
res = BaseAPIAuthData()
|
445
|
+
api_auth_data = BaseAPIAuthData(
|
446
|
+
require_api_key_string=require_api_key_string,
|
447
|
+
require_token_string=require_token_string
|
448
|
+
)
|
448
449
|
|
449
450
|
# api_key
|
450
451
|
|
451
|
-
|
452
|
+
api_auth_data.api_key_string = api_key_string
|
452
453
|
|
453
|
-
if not
|
454
|
-
|
455
|
-
if not
|
456
|
-
|
457
|
-
if not
|
458
|
-
|
454
|
+
if not api_auth_data.api_key_string and "api_key" in request.headers.keys():
|
455
|
+
api_auth_data.api_key_string = request.headers["api_key"]
|
456
|
+
if not api_auth_data.api_key_string and "api-key" in request.headers.keys():
|
457
|
+
api_auth_data.api_key_string = request.headers["api-key"]
|
458
|
+
if not api_auth_data.api_key_string and "apikey" in request.headers.keys():
|
459
|
+
api_auth_data.api_key_string = request.headers["apikey"]
|
459
460
|
|
460
|
-
if not
|
461
|
-
|
462
|
-
if not
|
463
|
-
|
464
|
-
if not
|
465
|
-
|
466
|
-
|
467
|
-
_error_data["res.api_key_string"] = res.api_key_string
|
461
|
+
if not api_auth_data.api_key_string and "api_key" in request.query_params.keys():
|
462
|
+
api_auth_data.api_key_string = request.query_params["api_key"]
|
463
|
+
if not api_auth_data.api_key_string and "api-key" in request.query_params.keys():
|
464
|
+
api_auth_data.api_key_string = request.query_params["api-key"]
|
465
|
+
if not api_auth_data.api_key_string and "apikey" in request.query_params.keys():
|
466
|
+
api_auth_data.api_key_string = request.query_params["apikey"]
|
468
467
|
|
469
468
|
# token
|
470
469
|
|
471
|
-
|
472
|
-
|
473
|
-
if not res.token_string and "token" in request.headers.keys():
|
474
|
-
res.token_string = request.headers["token"]
|
470
|
+
api_auth_data.token_string = ac.credentials if ac and ac.credentials and ac.credentials.strip() else None
|
475
471
|
|
476
|
-
if not
|
477
|
-
|
478
|
-
if not res.token_string and "user-token" in request.headers.keys():
|
479
|
-
res.token_string = request.headers["user-token"]
|
480
|
-
if not res.token_string and "usertoken" in request.headers.keys():
|
481
|
-
res.token_string = request.headers["usertoken"]
|
472
|
+
if not api_auth_data.token_string and "token" in request.headers.keys():
|
473
|
+
api_auth_data.token_string = request.headers["token"]
|
482
474
|
|
483
|
-
if not
|
484
|
-
|
475
|
+
if not api_auth_data.token_string and "user_token" in request.headers.keys():
|
476
|
+
api_auth_data.token_string = request.headers["user_token"]
|
477
|
+
if not api_auth_data.token_string and "user-token" in request.headers.keys():
|
478
|
+
api_auth_data.token_string = request.headers["user-token"]
|
479
|
+
if not api_auth_data.token_string and "usertoken" in request.headers.keys():
|
480
|
+
api_auth_data.token_string = request.headers["usertoken"]
|
485
481
|
|
486
|
-
if not
|
487
|
-
|
488
|
-
if not res.token_string and "user-token" in request.query_params.keys():
|
489
|
-
res.token_string = request.query_params["user-token"]
|
490
|
-
if not res.token_string and "usertoken" in request.query_params.keys():
|
491
|
-
res.token_string = request.query_params["usertoken"]
|
482
|
+
if not api_auth_data.token_string and "token" in request.query_params.keys():
|
483
|
+
api_auth_data.token_string = request.query_params["token"]
|
492
484
|
|
493
|
-
if
|
494
|
-
|
495
|
-
if not
|
496
|
-
|
485
|
+
if not api_auth_data.token_string and "user_token" in request.query_params.keys():
|
486
|
+
api_auth_data.token_string = request.query_params["user_token"]
|
487
|
+
if not api_auth_data.token_string and "user-token" in request.query_params.keys():
|
488
|
+
api_auth_data.token_string = request.query_params["user-token"]
|
489
|
+
if not api_auth_data.token_string and "usertoken" in request.query_params.keys():
|
490
|
+
api_auth_data.token_string = request.query_params["usertoken"]
|
497
491
|
|
498
|
-
|
492
|
+
if api_auth_data.token_string:
|
493
|
+
api_auth_data.token_string = api_auth_data.token_string.strip()
|
494
|
+
if not api_auth_data.token_string:
|
495
|
+
api_auth_data.token_string = None
|
499
496
|
|
500
|
-
if require_api_key_string and not
|
497
|
+
if require_api_key_string and not api_auth_data.api_key_string:
|
501
498
|
raise APIException(
|
502
499
|
status_code=starlette.status.HTTP_401_UNAUTHORIZED,
|
503
500
|
error_code=ErrorSO.APIErrorCodes.cannot_authorize,
|
504
|
-
error_data=
|
501
|
+
error_data=safely_transfer_to_json_str_to_json_obj(api_auth_data.model_dump())
|
505
502
|
)
|
506
503
|
|
507
|
-
if require_token_string and not
|
504
|
+
if require_token_string and not api_auth_data.token_string:
|
508
505
|
raise APIException(
|
509
506
|
status_code=starlette.status.HTTP_401_UNAUTHORIZED,
|
510
507
|
error_code=ErrorSO.APIErrorCodes.cannot_authorize,
|
511
|
-
error_data=
|
508
|
+
error_data=safely_transfer_to_json_str_to_json_obj(api_auth_data.model_dump())
|
512
509
|
)
|
513
510
|
|
514
|
-
return
|
511
|
+
return api_auth_data
|
515
512
|
|
516
513
|
return func
|
517
514
|
|
@@ -95,7 +95,7 @@ arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css,sha256=jzPZlgJTFwSdSphk9C
|
|
95
95
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css.map,sha256=5wq8eXMLU6Zxb45orZPL1zAsBFJReFw6GjYqGpUX3hg,262650
|
96
96
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js,sha256=ffrLZHHEQ_g84A-ul3yWa10Kk09waOAxHcQXPuZuavg,339292
|
97
97
|
arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js.map,sha256=9UhIW7MqCOZPAz1Sl1IKfZUuhWU0p-LJqrnjjJD9Xhc,1159454
|
98
|
-
arpakitlib/ar_fastapi_util.py,sha256=
|
98
|
+
arpakitlib/ar_fastapi_util.py,sha256=1_Fopm982g9EPSvbBx9vO6E0LF8sKzmpMRhydOI9bgE,21095
|
99
99
|
arpakitlib/ar_file_storage_in_dir_util.py,sha256=D3e3rGuHoI6xqAA5mVvEpVVpOWY1jyjNsjj2UhyHRbE,3674
|
100
100
|
arpakitlib/ar_file_util.py,sha256=XiwmeycxoLqtYnGOu5q6IEaJJXilZvtLvsKDKtwqSLY,137
|
101
101
|
arpakitlib/ar_hash_util.py,sha256=Iqy6KBAOLBQMFLWv676boI5sV7atT2B-fb7aCdHOmIQ,340
|
@@ -126,9 +126,9 @@ arpakitlib/ar_str_util.py,sha256=AhcdrEm-pXRilCaDWCdTfVkQSy0SnbE52ur43Ltr6cI,212
|
|
126
126
|
arpakitlib/ar_type_util.py,sha256=5nDnXL5Oyozlg8XvxMrogsoYiG8_atItg46A0mtv-pk,2025
|
127
127
|
arpakitlib/ar_yookassa_api_client_util.py,sha256=5GMvu8paByni8buhc1vpHB7n6oXe0gPfj1LSvnyZCrQ,5307
|
128
128
|
arpakitlib/ar_zabbix_util.py,sha256=Q-VR4MvoZ9aHwZeYZr9G3LwN-ANx1T5KFmF6pvPM-9M,6402
|
129
|
-
arpakitlib-1.6.
|
130
|
-
arpakitlib-1.6.
|
131
|
-
arpakitlib-1.6.
|
132
|
-
arpakitlib-1.6.
|
133
|
-
arpakitlib-1.6.
|
134
|
-
arpakitlib-1.6.
|
129
|
+
arpakitlib-1.6.90.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
|
130
|
+
arpakitlib-1.6.90.dist-info/METADATA,sha256=9jfwerueMneOaNsQrw6wXgcHIMmHZHA4NQCRa-EPtsI,2739
|
131
|
+
arpakitlib-1.6.90.dist-info/NOTICE,sha256=95aUzaPJjVpDsGAsNzVnq7tHTxAl0s5UFznCTkVCau4,763
|
132
|
+
arpakitlib-1.6.90.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
133
|
+
arpakitlib-1.6.90.dist-info/entry_points.txt,sha256=VHkTDXDOMrgcNzGfKhEhoOIIz6T8Kkt46hy95Zc1iL0,74
|
134
|
+
arpakitlib-1.6.90.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|