huace-aigc-auth-client 1.1.9__tar.gz → 1.1.10__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.9/huace_aigc_auth_client.egg-info → huace_aigc_auth_client-1.1.10}/PKG-INFO +1 -1
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/huace_aigc_auth_client/__init__.py +1 -1
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/huace_aigc_auth_client/legacy_adapter.py +41 -18
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10/huace_aigc_auth_client.egg-info}/PKG-INFO +1 -1
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/pyproject.toml +1 -1
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/LICENSE +0 -0
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/MANIFEST.in +0 -0
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/QUICK_START.txt +0 -0
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/README.md +0 -0
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/huace_aigc_auth_client/sdk.py +0 -0
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/huace_aigc_auth_client/webhook.py +0 -0
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/huace_aigc_auth_client/webhook_flask.py +0 -0
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/huace_aigc_auth_client.egg-info/SOURCES.txt +0 -0
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/huace_aigc_auth_client.egg-info/dependency_links.txt +0 -0
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/huace_aigc_auth_client.egg-info/requires.txt +0 -0
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/huace_aigc_auth_client.egg-info/top_level.txt +0 -0
- {huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/setup.cfg +0 -0
|
@@ -214,6 +214,41 @@ class LegacySystemAdapter(ABC):
|
|
|
214
214
|
user_id = await self._create_user_async(user_data)
|
|
215
215
|
return {"created": True, "user_id": user_id}
|
|
216
216
|
|
|
217
|
+
async def sync_user_to_auth(self, legacy_user: LegacyUserData) -> Dict[str, Any]:
|
|
218
|
+
"""同步单个旧系统用户到 aigc-auth(默认实现)
|
|
219
|
+
|
|
220
|
+
子类可以选择性覆盖此方法以自定义同步逻辑。
|
|
221
|
+
|
|
222
|
+
Args:
|
|
223
|
+
legacy_user: 旧系统用户数据
|
|
224
|
+
Returns:
|
|
225
|
+
Dict: 同步结果
|
|
226
|
+
"""
|
|
227
|
+
if not self.auth_client:
|
|
228
|
+
logger.error("auth_client is required for sync_user_to_auth")
|
|
229
|
+
raise ValueError("auth_client is required for sync_user_to_auth. Please provide it in constructor.")
|
|
230
|
+
|
|
231
|
+
logger.info(f"Syncing legacy user to auth: {legacy_user.to_dict()}")
|
|
232
|
+
auth_data = self.transform_legacy_to_auth(legacy_user)
|
|
233
|
+
|
|
234
|
+
# 获取密码(支持新的元组返回格式)
|
|
235
|
+
password_result = self.get_password_for_sync(legacy_user)
|
|
236
|
+
if isinstance(password_result, tuple):
|
|
237
|
+
password, is_hashed = password_result
|
|
238
|
+
else:
|
|
239
|
+
password, is_hashed = password_result, False
|
|
240
|
+
|
|
241
|
+
# 根据是否已加密选择不同的字段
|
|
242
|
+
if is_hashed:
|
|
243
|
+
auth_data["password_hashed"] = password
|
|
244
|
+
else:
|
|
245
|
+
auth_data["password"] = password
|
|
246
|
+
|
|
247
|
+
result = await self.auth_client.sync_user_to_auth(auth_data)
|
|
248
|
+
logger.info(f"Sync result for user {legacy_user.get('username')}: {result}")
|
|
249
|
+
|
|
250
|
+
return result
|
|
251
|
+
|
|
217
252
|
async def batch_sync_to_auth(self) -> Dict[str, Any]:
|
|
218
253
|
"""批量同步旧系统用户到 aigc-auth(默认实现)
|
|
219
254
|
|
|
@@ -239,22 +274,7 @@ class LegacySystemAdapter(ABC):
|
|
|
239
274
|
|
|
240
275
|
for user in users:
|
|
241
276
|
try:
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
# 获取密码(支持新的元组返回格式)
|
|
245
|
-
password_result = self.get_password_for_sync(user)
|
|
246
|
-
if isinstance(password_result, tuple):
|
|
247
|
-
password, is_hashed = password_result
|
|
248
|
-
else:
|
|
249
|
-
password, is_hashed = password_result, False
|
|
250
|
-
|
|
251
|
-
# 根据是否已加密选择不同的字段
|
|
252
|
-
if is_hashed:
|
|
253
|
-
auth_data["password_hashed"] = password
|
|
254
|
-
else:
|
|
255
|
-
auth_data["password"] = password
|
|
256
|
-
|
|
257
|
-
result = self.auth_client.sync_user_to_auth(auth_data)
|
|
277
|
+
result = await self.sync_user_to_auth(user)
|
|
258
278
|
logger.info(f"Sync result for user {user.get('username')}: {result}")
|
|
259
279
|
|
|
260
280
|
if result.get("success"):
|
|
@@ -297,12 +317,15 @@ class LegacySystemAdapter(ABC):
|
|
|
297
317
|
legacy_data = self.transform_auth_to_legacy(data)
|
|
298
318
|
|
|
299
319
|
# 获取密码
|
|
300
|
-
password_result = self.get_password_for_sync()
|
|
320
|
+
password_result = self.get_password_for_sync(legacy_data)
|
|
301
321
|
if isinstance(password_result, tuple):
|
|
302
322
|
password, is_hashed = password_result
|
|
303
323
|
else:
|
|
304
324
|
password, is_hashed = password_result, False
|
|
305
|
-
|
|
325
|
+
if is_hashed:
|
|
326
|
+
legacy_data["password_hashed"] = password
|
|
327
|
+
else:
|
|
328
|
+
legacy_data["password"] = password
|
|
306
329
|
|
|
307
330
|
# 创建或更新用户
|
|
308
331
|
logger.info(f"Handling {event} event for user: {legacy_data}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/huace_aigc_auth_client/sdk.py
RENAMED
|
File without changes
|
{huace_aigc_auth_client-1.1.9 → huace_aigc_auth_client-1.1.10}/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
|