nc-user-terminator 0.1.7__py3-none-any.whl → 0.1.9__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.
Potentially problematic release.
This version of nc-user-terminator might be problematic. Click here for more details.
- nc_user_manager/client.py +16 -11
- {nc_user_terminator-0.1.7.dist-info → nc_user_terminator-0.1.9.dist-info}/METADATA +5 -1
- {nc_user_terminator-0.1.7.dist-info → nc_user_terminator-0.1.9.dist-info}/RECORD +5 -5
- {nc_user_terminator-0.1.7.dist-info → nc_user_terminator-0.1.9.dist-info}/WHEEL +0 -0
- {nc_user_terminator-0.1.7.dist-info → nc_user_terminator-0.1.9.dist-info}/top_level.txt +0 -0
nc_user_manager/client.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
from typing import Optional, Dict, Any
|
|
3
3
|
|
|
4
|
-
from cache import MemoryCache, BaseCache, AsyncRedisCache
|
|
5
|
-
from models import UserResponse, OAuth2AuthorizeResponse, CallbackResponse
|
|
6
|
-
from exceptions import OAuthError
|
|
7
|
-
from utils import request
|
|
4
|
+
from .cache import MemoryCache, BaseCache, AsyncRedisCache
|
|
5
|
+
from .models import UserResponse, OAuth2AuthorizeResponse, CallbackResponse
|
|
6
|
+
from .exceptions import OAuthError
|
|
7
|
+
from .utils import request
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
PRODUCT_HEADER = "X-Product-Code"
|
|
@@ -14,8 +14,8 @@ DEFAULT_TTL = 3600
|
|
|
14
14
|
class OAuthClient:
|
|
15
15
|
def __init__(
|
|
16
16
|
self,
|
|
17
|
-
base_url: Optional[str],
|
|
18
17
|
product_code: str,
|
|
18
|
+
base_url: Optional[str] = None,
|
|
19
19
|
redirect_url: Optional[str] = None,
|
|
20
20
|
single_session: bool = False,
|
|
21
21
|
cache: Optional[BaseCache] = None,
|
|
@@ -219,12 +219,13 @@ class OAuthClient:
|
|
|
219
219
|
return UserResponse(res_dict)
|
|
220
220
|
|
|
221
221
|
async def say_my_name_async(self, token: str) -> UserResponse:
|
|
222
|
-
if not self._async_cache:
|
|
223
|
-
raise RuntimeError("异步方法只支持异步缓存,请传入 async_cache")
|
|
224
|
-
|
|
225
222
|
"""异步获取当前用户"""
|
|
226
223
|
key = f"user:{token}"
|
|
227
|
-
|
|
224
|
+
if self._async_cache:
|
|
225
|
+
data = await self._cache.get(key)
|
|
226
|
+
else:
|
|
227
|
+
data = self._cache.get(key)
|
|
228
|
+
|
|
228
229
|
if data:
|
|
229
230
|
return UserResponse(data)
|
|
230
231
|
|
|
@@ -267,8 +268,12 @@ class OAuthClient:
|
|
|
267
268
|
headers = self._headers({"Authorization": f"Bearer {token}"})
|
|
268
269
|
resp = await self._arequest("POST", f"{self._base_url}/api/auth/logout", headers=headers)
|
|
269
270
|
|
|
270
|
-
|
|
271
|
-
|
|
271
|
+
if self._async_cache:
|
|
272
|
+
data = await self._cache.get(f"user:{token}")
|
|
273
|
+
await self._uncache_user_async(token, data)
|
|
274
|
+
else:
|
|
275
|
+
data = self._cache.get(f"user:{token}")
|
|
276
|
+
self._uncache_user(token, data)
|
|
272
277
|
return resp
|
|
273
278
|
|
|
274
279
|
async def main():
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nc-user-terminator
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.9
|
|
4
4
|
Summary: OAuth client wrapper for multi-tenant projects
|
|
5
5
|
Author: bw_song
|
|
6
6
|
Author-email: m132777096902@gmail.com
|
|
@@ -17,3 +17,7 @@ Dynamic: requires-python
|
|
|
17
17
|
- 默认连接地址
|
|
18
18
|
+ v0.1.7
|
|
19
19
|
- 映射host
|
|
20
|
+
+ v0.1.8
|
|
21
|
+
- 调整相对路径
|
|
22
|
+
+ v0.1.9
|
|
23
|
+
- 修改缓存配置
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
nc_user_manager/__init__.py,sha256=fF3FZD0XUW5YCfTbBeJs3RK-Mnm3IQ7lns6Eb_tMqPU,238
|
|
2
2
|
nc_user_manager/cache.py,sha256=u9ioXDwHmEJHRB4VKI4JU_pp-8Y5O4bLPm8-pwqiMVc,2273
|
|
3
|
-
nc_user_manager/client.py,sha256=
|
|
3
|
+
nc_user_manager/client.py,sha256=BEryWh_uooiSDZaLeKokawKG7U_hWB1mA9-fwVUSWrI,11221
|
|
4
4
|
nc_user_manager/exceptions.py,sha256=yUMDrh1HHZF36UUadQNHvJlDgEYSYoYOObs8Q11fjrE,351
|
|
5
5
|
nc_user_manager/models.py,sha256=mDK7zskIcaThxvUUTWVf6eMasw7YaA3hDGVVSd1ZJgo,1088
|
|
6
6
|
nc_user_manager/utils.py,sha256=gxFSaUq0oiymIlvHITu2L7EkU2ZYQmW2q_okmUxGBeU,2319
|
|
7
|
-
nc_user_terminator-0.1.
|
|
8
|
-
nc_user_terminator-0.1.
|
|
9
|
-
nc_user_terminator-0.1.
|
|
10
|
-
nc_user_terminator-0.1.
|
|
7
|
+
nc_user_terminator-0.1.9.dist-info/METADATA,sha256=8bfDGjP5d-D94vpspEoA1hq_TmYAng--GEhzWBTwwKs,506
|
|
8
|
+
nc_user_terminator-0.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
nc_user_terminator-0.1.9.dist-info/top_level.txt,sha256=kOAUtl6RYo-x3vMJL8It3KCJLoIFPvMUiAAyXjPQTYA,16
|
|
10
|
+
nc_user_terminator-0.1.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|