huace-aigc-auth-client 1.1.3__py3-none-any.whl → 1.1.4__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.
- huace_aigc_auth_client/__init__.py +1 -1
- huace_aigc_auth_client/sdk.py +7 -4
- {huace_aigc_auth_client-1.1.3.dist-info → huace_aigc_auth_client-1.1.4.dist-info}/METADATA +1 -1
- huace_aigc_auth_client-1.1.4.dist-info/RECORD +8 -0
- huace_aigc_auth_client-1.1.3.dist-info/RECORD +0 -8
- {huace_aigc_auth_client-1.1.3.dist-info → huace_aigc_auth_client-1.1.4.dist-info}/WHEEL +0 -0
- {huace_aigc_auth_client-1.1.3.dist-info → huace_aigc_auth_client-1.1.4.dist-info}/licenses/LICENSE +0 -0
- {huace_aigc_auth_client-1.1.3.dist-info → huace_aigc_auth_client-1.1.4.dist-info}/top_level.txt +0 -0
huace_aigc_auth_client/sdk.py
CHANGED
|
@@ -577,7 +577,7 @@ class AuthMiddleware:
|
|
|
577
577
|
return None
|
|
578
578
|
return authorization[7:]
|
|
579
579
|
|
|
580
|
-
async def fastapi_middleware(self, request, call_next):
|
|
580
|
+
async def fastapi_middleware(self, request, call_next, user_info_callback: Callable = None):
|
|
581
581
|
"""
|
|
582
582
|
FastAPI 中间件
|
|
583
583
|
|
|
@@ -613,22 +613,23 @@ class AuthMiddleware:
|
|
|
613
613
|
forwarded_proto = request.headers.get("x-forwarded-proto")
|
|
614
614
|
if forwarded_proto:
|
|
615
615
|
request.scope["scheme"] = forwarded_proto
|
|
616
|
+
if user_info_callback:
|
|
617
|
+
await user_info_callback(request, user_info)
|
|
616
618
|
except AigcAuthError as e:
|
|
617
619
|
return JSONResponse(
|
|
618
620
|
status_code=401,
|
|
619
621
|
content={"code": e.code, "message": e.message, "data": None}
|
|
620
622
|
)
|
|
621
|
-
|
|
622
623
|
return await call_next(request)
|
|
623
624
|
|
|
624
|
-
def flask_before_request(self):
|
|
625
|
+
def flask_before_request(self, user_info_callback: Callable = None):
|
|
625
626
|
"""
|
|
626
627
|
Flask before_request 处理器
|
|
627
628
|
|
|
628
629
|
使用方法:
|
|
629
630
|
@app.before_request
|
|
630
631
|
def before_request():
|
|
631
|
-
return auth_middleware.flask_before_request()
|
|
632
|
+
return auth_middleware.flask_before_request(user_info_callback=user_info_callback)
|
|
632
633
|
"""
|
|
633
634
|
from flask import request, jsonify, g
|
|
634
635
|
|
|
@@ -654,6 +655,8 @@ class AuthMiddleware:
|
|
|
654
655
|
user_info = self.client.get_user_info(token)
|
|
655
656
|
# 将用户信息存储到 flask.g
|
|
656
657
|
g.user_info = user_info
|
|
658
|
+
if user_info_callback:
|
|
659
|
+
user_info_callback(request, user_info)
|
|
657
660
|
except AigcAuthError as e:
|
|
658
661
|
return jsonify({
|
|
659
662
|
"code": e.code,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
huace_aigc_auth_client/__init__.py,sha256=isMBleAvICiYwHXv0fm6qf-nrvdIMIePGZbrrG_rQws,2163
|
|
2
|
+
huace_aigc_auth_client/legacy_adapter.py,sha256=lCxpwROHZd0RG0dVp6AidQQRpFv6H8DvVzjrYHRDZFg,21515
|
|
3
|
+
huace_aigc_auth_client/sdk.py,sha256=4Azj2TPOCLWv6dTaAqw--_Uh-Gzpp0KhpxOEBGONG48,22749
|
|
4
|
+
huace_aigc_auth_client-1.1.4.dist-info/licenses/LICENSE,sha256=z7dgC7KljhBLNvKjN15391nMj3aLt0gbud8-Yf1F8EQ,1063
|
|
5
|
+
huace_aigc_auth_client-1.1.4.dist-info/METADATA,sha256=ly5bJH-amh0jsbg_ArABrq8mvqOfCQ0nYz1UtdD0Ka4,20084
|
|
6
|
+
huace_aigc_auth_client-1.1.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
+
huace_aigc_auth_client-1.1.4.dist-info/top_level.txt,sha256=kbv0nQ6PQ0JVneWPH7O2AbtlJnP7AjvFJ6JjM6ZEBxo,23
|
|
8
|
+
huace_aigc_auth_client-1.1.4.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
huace_aigc_auth_client/__init__.py,sha256=WwdgR8RP5SkueieSv6HCjIirIZdwTDpyGTaBzpENK5g,2163
|
|
2
|
-
huace_aigc_auth_client/legacy_adapter.py,sha256=lCxpwROHZd0RG0dVp6AidQQRpFv6H8DvVzjrYHRDZFg,21515
|
|
3
|
-
huace_aigc_auth_client/sdk.py,sha256=46kkNDmWcce4BkSAT9zn5n8XdURDns3YtXIIfe8TGDU,22453
|
|
4
|
-
huace_aigc_auth_client-1.1.3.dist-info/licenses/LICENSE,sha256=z7dgC7KljhBLNvKjN15391nMj3aLt0gbud8-Yf1F8EQ,1063
|
|
5
|
-
huace_aigc_auth_client-1.1.3.dist-info/METADATA,sha256=nATeZZKa_zxe1vVU5KF6jNiASCWPwbDS3yWqpv7FtzE,20084
|
|
6
|
-
huace_aigc_auth_client-1.1.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
7
|
-
huace_aigc_auth_client-1.1.3.dist-info/top_level.txt,sha256=kbv0nQ6PQ0JVneWPH7O2AbtlJnP7AjvFJ6JjM6ZEBxo,23
|
|
8
|
-
huace_aigc_auth_client-1.1.3.dist-info/RECORD,,
|
|
File without changes
|
{huace_aigc_auth_client-1.1.3.dist-info → huace_aigc_auth_client-1.1.4.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{huace_aigc_auth_client-1.1.3.dist-info → huace_aigc_auth_client-1.1.4.dist-info}/top_level.txt
RENAMED
|
File without changes
|