rainycode 1.5.8__tar.gz → 1.6.0__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.
- {rainycode-1.5.8 → rainycode-1.6.0}/PKG-INFO +1 -1
- {rainycode-1.5.8 → rainycode-1.6.0}/common_base/aiorequests.py +13 -3
- {rainycode-1.5.8 → rainycode-1.6.0}/common_servers/api/wechat_api.py +4 -1
- {rainycode-1.5.8 → rainycode-1.6.0}/common_servers/service/auth_svc.py +5 -2
- {rainycode-1.5.8 → rainycode-1.6.0}/pyproject.toml +1 -1
- {rainycode-1.5.8 → rainycode-1.6.0}/rainycode.egg-info/PKG-INFO +1 -1
- {rainycode-1.5.8 → rainycode-1.6.0}/common_base/consts.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_base/exception.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_base/logging.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_base/response.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_depends/auth_depend.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_models/__init__.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_models/base_model.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_models/file_model.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_models/user_model.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_models/wechat_model.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_servers/api/auth_api.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_servers/router.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_servers/schemas/auth_schema.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_servers/service/file_svc.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_servers/service/wechat_svc.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_utils/bcrypt_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_utils/captcha_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_utils/datetime_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_utils/ip_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_utils/jwt_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_utils/snowflake_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/common_utils/wechat_util.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/core/base_config.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/core/databases/aiodb.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/core/databases/aioredis.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/core/middleware/http_middleware.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/core/start.py +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/rainycode.egg-info/SOURCES.txt +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/rainycode.egg-info/dependency_links.txt +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/rainycode.egg-info/requires.txt +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/rainycode.egg-info/top_level.txt +0 -0
- {rainycode-1.5.8 → rainycode-1.6.0}/setup.cfg +0 -0
|
@@ -17,7 +17,9 @@ _CONNECTOR: aiohttp.TCPConnector | None = None
|
|
|
17
17
|
|
|
18
18
|
def _get_connector() -> aiohttp.TCPConnector:
|
|
19
19
|
global _CONNECTOR
|
|
20
|
-
|
|
20
|
+
# 判空之外还要判 closed:连接池一旦被别处关闭(见下方 connector_owner 说明),
|
|
21
|
+
# 这里能重建,避免后续所有请求都拿到已关闭的实例。
|
|
22
|
+
if _CONNECTOR is None or _CONNECTOR.closed:
|
|
21
23
|
_CONNECTOR = aiohttp.TCPConnector(ssl=_SSL_CONTEXT, limit=300, limit_per_host=100)
|
|
22
24
|
return _CONNECTOR
|
|
23
25
|
|
|
@@ -36,8 +38,13 @@ def parse_url(url, params=None, suffix=None):
|
|
|
36
38
|
|
|
37
39
|
async def get(url, params=None, headers=None, suffix=None):
|
|
38
40
|
url = parse_url(url, params, suffix)
|
|
41
|
+
# connector_owner=False 必须显式传:ClientSession 默认 owner=True,退出 async with 时
|
|
42
|
+
# 会连带 close 掉模块级共享的 _CONNECTOR;之后新 session 一建出来即 closed,
|
|
43
|
+
# session.get() 直接抛 RuntimeError: Session is closed(进程重启前不再自愈)。
|
|
39
44
|
async with (
|
|
40
|
-
aiohttp.ClientSession(
|
|
45
|
+
aiohttp.ClientSession(
|
|
46
|
+
connector=_get_connector(), trust_env=True, connector_owner=False
|
|
47
|
+
) as session,
|
|
41
48
|
session.get(url, headers=headers) as response,
|
|
42
49
|
):
|
|
43
50
|
text = await response.text()
|
|
@@ -47,8 +54,11 @@ async def get(url, params=None, headers=None, suffix=None):
|
|
|
47
54
|
async def post(url, data=None, headers=None):
|
|
48
55
|
if isinstance(data, dict):
|
|
49
56
|
data = json.dumps(data)
|
|
57
|
+
# connector_owner=False 的理由同 get():共享连接池不归单次 session 所有。
|
|
50
58
|
async with (
|
|
51
|
-
aiohttp.ClientSession(
|
|
59
|
+
aiohttp.ClientSession(
|
|
60
|
+
connector=_get_connector(), trust_env=True, connector_owner=False
|
|
61
|
+
) as session,
|
|
52
62
|
session.post(url, data=data, headers=headers) as response,
|
|
53
63
|
):
|
|
54
64
|
text = await response.text()
|
|
@@ -89,7 +89,10 @@ async def wechat_oauth_callback(
|
|
|
89
89
|
"error": error,
|
|
90
90
|
"error_description": error_description or "用户拒绝授权",
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
# redirect_uri 现在可能已带目标路由(...#/pages/xxx),拼接符按需选,
|
|
93
|
+
# 使错误信息落在该页自己的 query 上(路由之后)
|
|
94
|
+
sep = "&" if "?" in redirect_uri else "?"
|
|
95
|
+
error_url = f"{redirect_uri}{sep}{urlencode(params)}"
|
|
93
96
|
return RedirectResponse(url=error_url, status_code=302)
|
|
94
97
|
|
|
95
98
|
raise CustomException(msg="授权失败")
|
|
@@ -531,7 +531,10 @@ class AuthService:
|
|
|
531
531
|
if state:
|
|
532
532
|
params["state"] = state
|
|
533
533
|
|
|
534
|
-
#
|
|
534
|
+
# 凭证一律挂在 query 上(token 不落 fragment):redirect_uri 由前端带上目标页
|
|
535
|
+
# 路由(https://host/#/pages/xxx),拼出来即 ...#/pages/xxx?access_token=..
|
|
536
|
+
# 它自身已带参数时(...#/pages/xxx?id=3)用 & 续接。
|
|
535
537
|
fragment = urlencode(params)
|
|
536
|
-
|
|
538
|
+
sep = "&" if "?" in redirect_uri else "?"
|
|
539
|
+
redirect_url = f"{redirect_uri}{sep}{fragment}"
|
|
537
540
|
return RedirectResponse(url=redirect_url, status_code=302)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|