huace-aigc-auth-client 1.1.25__tar.gz → 1.1.27__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.
- {huace_aigc_auth_client-1.1.25/huace_aigc_auth_client.egg-info → huace_aigc_auth_client-1.1.27}/PKG-INFO +1 -1
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client/__init__.py +1 -1
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client/sdk.py +16 -11
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27/huace_aigc_auth_client.egg-info}/PKG-INFO +1 -1
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/pyproject.toml +1 -1
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/LICENSE +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/MANIFEST.in +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/QUICK_START.txt +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/README.md +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client/api_stats_collector.py +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client/legacy_adapter.py +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client/user_context.py +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client/webhook.py +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client/webhook_flask.py +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client.egg-info/SOURCES.txt +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client.egg-info/dependency_links.txt +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client.egg-info/requires.txt +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client.egg-info/top_level.txt +0 -0
- {huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/setup.cfg +0 -0
{huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client/sdk.py
RENAMED
|
@@ -672,6 +672,14 @@ class AuthMiddleware:
|
|
|
672
672
|
|
|
673
673
|
# 获取请求体(使用白名单方式,只处理已知安全的内容类型)
|
|
674
674
|
content_type = request.headers.get("content-type", "").lower()
|
|
675
|
+
# 读取请求体(需要特殊处理以避免消耗流)
|
|
676
|
+
body = b""
|
|
677
|
+
if request.method in ["POST", "PUT", "PATCH"]:
|
|
678
|
+
try:
|
|
679
|
+
body = await request.body()
|
|
680
|
+
except:
|
|
681
|
+
pass
|
|
682
|
+
params["request_body"] = body.decode('utf-8', errors='ignore')
|
|
675
683
|
|
|
676
684
|
if "application/json" in content_type:
|
|
677
685
|
try:
|
|
@@ -698,14 +706,6 @@ class AuthMiddleware:
|
|
|
698
706
|
params["form_params"] = form_params
|
|
699
707
|
except Exception:
|
|
700
708
|
pass
|
|
701
|
-
elif content_type.startswith('text/'):
|
|
702
|
-
# 只读取文本类型的请求体,且限制大小避免内存问题
|
|
703
|
-
try:
|
|
704
|
-
body = await request.body()
|
|
705
|
-
if body and len(body) < 10240: # 限制10KB避免内存问题
|
|
706
|
-
params["request_body"] = body.decode('utf-8')
|
|
707
|
-
except Exception:
|
|
708
|
-
pass
|
|
709
709
|
# 其他类型(如 application/octet-stream 等二进制流)直接跳过,不读取
|
|
710
710
|
|
|
711
711
|
return params
|
|
@@ -852,9 +852,6 @@ class AuthMiddleware:
|
|
|
852
852
|
|
|
853
853
|
path = request.url.path
|
|
854
854
|
start_time = time.time()
|
|
855
|
-
|
|
856
|
-
# 收集请求参数
|
|
857
|
-
request_params = await self._collect_fastapi_request_params(request) if self.enable_stats else None
|
|
858
855
|
|
|
859
856
|
# 检查是否跳过
|
|
860
857
|
if self._should_skip(path):
|
|
@@ -867,6 +864,8 @@ class AuthMiddleware:
|
|
|
867
864
|
if not token:
|
|
868
865
|
logger.warning("AuthMiddleware未提供认证信息")
|
|
869
866
|
response_time = time.time() - start_time
|
|
867
|
+
# 收集请求参数
|
|
868
|
+
request_params = await self._collect_fastapi_request_params(request) if self.enable_stats else None
|
|
870
869
|
self._collect_stats(path, request.method, 401, response_time, "", "未提供认证信息", request_params)
|
|
871
870
|
return JSONResponse(
|
|
872
871
|
status_code=401,
|
|
@@ -885,6 +884,8 @@ class AuthMiddleware:
|
|
|
885
884
|
except AigcAuthError as e:
|
|
886
885
|
logger.error(f"AuthMiddleware认证失败: {e.message}")
|
|
887
886
|
response_time = time.time() - start_time
|
|
887
|
+
# 收集请求参数
|
|
888
|
+
request_params = await self._collect_fastapi_request_params(request) if self.enable_stats else None
|
|
888
889
|
self._collect_stats(path, request.method, 401, response_time, token, e.message, request_params)
|
|
889
890
|
return JSONResponse(
|
|
890
891
|
status_code=401,
|
|
@@ -895,9 +896,13 @@ class AuthMiddleware:
|
|
|
895
896
|
try:
|
|
896
897
|
response = await call_next(request)
|
|
897
898
|
response_time = time.time() - start_time
|
|
899
|
+
# 收集请求参数
|
|
900
|
+
request_params = await self._collect_fastapi_request_params(request) if self.enable_stats else None
|
|
898
901
|
self._collect_stats(path, request.method, response.status_code, response_time, token, None, request_params)
|
|
899
902
|
return response
|
|
900
903
|
except Exception as e:
|
|
904
|
+
# 收集请求参数
|
|
905
|
+
request_params = await self._collect_fastapi_request_params(request) if self.enable_stats else None
|
|
901
906
|
response_time = time.time() - start_time
|
|
902
907
|
self._collect_stats(path, request.method, 500, response_time, token, str(e), request_params)
|
|
903
908
|
raise
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huace_aigc_auth_client-1.1.25 → huace_aigc_auth_client-1.1.27}/huace_aigc_auth_client/webhook.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|