huace-aigc-auth-client 1.1.7__py3-none-any.whl → 1.1.8__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.
@@ -98,4 +98,4 @@ __all__ = [
98
98
  "register_webhook_router",
99
99
  "verify_webhook_signature",
100
100
  ]
101
- __version__ = "1.1.7"
101
+ __version__ = "1.1.8"
@@ -147,6 +147,7 @@ class LegacySystemAdapter(ABC):
147
147
  Returns:
148
148
  Optional[LegacyUserData]: 用户数据,不存在返回 None
149
149
  """
150
+ logger.info(f"Fetching user by username asynchronously: {username}")
150
151
  raise NotImplementedError("Subclass must implement get_user_by_username_async method")
151
152
 
152
153
  @abstractmethod
@@ -159,6 +160,7 @@ class LegacySystemAdapter(ABC):
159
160
  Returns:
160
161
  Optional[Any]: 创建的用户 ID 或其他标识
161
162
  """
163
+ logger.info(f"Creating user with data: {user_data}")
162
164
  raise NotImplementedError("Subclass must implement _create_user_async method")
163
165
 
164
166
  @abstractmethod
@@ -172,6 +174,7 @@ class LegacySystemAdapter(ABC):
172
174
  Returns:
173
175
  bool: 更新成功返回 True
174
176
  """
177
+ logger.info(f"Updating user: {username} with data: {user_data}")
175
178
  raise NotImplementedError("Subclass must implement _update_user_async method")
176
179
 
177
180
  @abstractmethod
@@ -184,6 +187,7 @@ class LegacySystemAdapter(ABC):
184
187
  Returns:
185
188
  bool: 删除成功返回 True
186
189
  """
190
+ logger.info(f"Deleting user: {username}")
187
191
  raise NotImplementedError("Subclass must implement _delete_user_async method")
188
192
 
189
193
  @abstractmethod
@@ -193,6 +197,7 @@ class LegacySystemAdapter(ABC):
193
197
  Returns:
194
198
  List[LegacyUserData]: 所有用户数据列表
195
199
  """
200
+ logger.info("Fetching all users from legacy system asynchronously")
196
201
  raise NotImplementedError("Subclass must implement get_all_users_async method")
197
202
 
198
203
  async def upsert_user_async(self, user_data: Dict[str, Any], auth_data: Dict[str, Any] = None) -> Dict[str, Any]:
@@ -208,6 +213,7 @@ class LegacySystemAdapter(ABC):
208
213
  """
209
214
  username = user_data.get("username")
210
215
  if not username:
216
+ logger.error("username is required for upsert operation")
211
217
  raise ValueError("username is required for upsert operation")
212
218
 
213
219
  # 检查用户是否存在
@@ -216,6 +222,7 @@ class LegacySystemAdapter(ABC):
216
222
  if existing:
217
223
  # 用户存在,执行更新
218
224
  if not auth_data or auth_data.get("updatedFields") is None or len(auth_data.get("updatedFields")) == 0:
225
+ logger.info(f"No updatedFields provided for user: {username}, skipping update")
219
226
  # 如果没有提供 auth_data 或 updatedFields,则不更新
220
227
  return {"created": False, "user_id": existing.get("id")}
221
228
  await self._update_user_async(username, user_data)
@@ -234,8 +241,10 @@ class LegacySystemAdapter(ABC):
234
241
  Dict: 同步结果统计
235
242
  """
236
243
  if not self.auth_client:
244
+ logger.error("auth_client is required for batch_sync_to_auth")
237
245
  raise ValueError("auth_client is required for batch_sync_to_auth. Please provide it in constructor.")
238
246
 
247
+ logger.info("Starting batch sync from legacy system to aigc-auth")
239
248
  users = await self.get_all_users_async()
240
249
 
241
250
  results = {
@@ -264,6 +273,7 @@ class LegacySystemAdapter(ABC):
264
273
  auth_data["password"] = password
265
274
 
266
275
  result = self.auth_client.sync_user_to_auth(auth_data)
276
+ logger.info(f"Sync result for user {user.get('username')}: {result}")
267
277
 
268
278
  if result.get("success"):
269
279
  if result.get("created"):
@@ -277,6 +287,7 @@ class LegacySystemAdapter(ABC):
277
287
  "error": result.get("message")
278
288
  })
279
289
  except Exception as e:
290
+ logger.error(f"Error syncing user {user.get('username')}: {e}")
280
291
  results["failed"] += 1
281
292
  results["errors"].append({
282
293
  "user": user.get("username"),
@@ -311,6 +322,7 @@ class LegacySystemAdapter(ABC):
311
322
  legacy_data["password"] = password
312
323
 
313
324
  # 创建或更新用户
325
+ logger.info(f"Handling {event} event for user: {legacy_data}")
314
326
  result = await self.upsert_user_async(legacy_data)
315
327
 
316
328
  return {
@@ -321,18 +333,23 @@ class LegacySystemAdapter(ABC):
321
333
  }
322
334
 
323
335
  elif event == "user.deleted":
336
+ logger.info("Handling user.deleted event")
324
337
  # 禁用用户而不是删除
325
338
  username = data.get("username")
326
339
  if not username:
340
+ logger.error("username is required for user.deleted event")
327
341
  logger.error("username is required for user.deleted event")
328
342
  return {"success": False, "message": "username is required for user.deleted event"}
343
+ logger.info(f"Disabling user: {username}")
329
344
  await self._delete_user_async(username)
330
345
 
331
346
  return {"success": True, "message": "User disabled"}
332
347
 
333
348
  elif event == "user.init_sync_auth":
349
+ logger.info("Handling user.init_sync_auth event")
334
350
  # 初始化同步:批量同步旧系统用户到 aigc-auth
335
351
  if not self.auth_client:
352
+ logger.error("auth_client is required for init_sync_auth event")
336
353
  return {"success": False, "message": "auth_client is required for init_sync_auth event. Please provide it in constructor."}
337
354
 
338
355
  results = await self.batch_sync_to_auth()
@@ -362,7 +379,7 @@ class LegacySystemAdapter(ABC):
362
379
 
363
380
  if auth_value is not None:
364
381
  result[mapping.legacy_field] = auth_value
365
-
382
+ logger.info(f"Transformed auth user({auth_user}) to legacy format: {result}")
366
383
  return result
367
384
 
368
385
  def transform_legacy_to_auth(self, legacy_user: LegacyUserData) -> Dict[str, Any]:
@@ -382,7 +399,7 @@ class LegacySystemAdapter(ABC):
382
399
 
383
400
  if legacy_value is not None:
384
401
  result[mapping.auth_field] = legacy_value
385
-
402
+ logger.info(f"Transformed legacy user({legacy_user}) to auth format: {result}")
386
403
  return result
387
404
 
388
405
  def get_password_for_sync(self, legacy_user: Optional[LegacyUserData] = None) -> tuple:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: huace-aigc-auth-client
3
- Version: 1.1.7
3
+ Version: 1.1.8
4
4
  Summary: 华策AIGC Auth Client - 提供 Token 验证、用户信息获取、权限检查、旧系统接入等功能
5
5
  Author-email: Huace <support@huace.com>
6
6
  License: MIT
@@ -45,7 +45,7 @@ pip install huace-aigc-auth-client
45
45
  AIGC_AUTH_APP_ID=your_app_id
46
46
  AIGC_AUTH_APP_SECRET=your_app_secret
47
47
 
48
- # 可选:鉴权服务地址(默认为生产环境)- 测试环境鉴权地址:https://auth-test.aigc.huacemedia.com/aigc-auth/api/v1
48
+ # 可选:鉴权服务地址(默认为生产环境)- 测试环境鉴权地址:http://auth-test.aigc.huacemedia.com/aigc-auth/api/v1
49
49
  AIGC_AUTH_BASE_URL=https://aigc-auth.huacemedia.com/aigc-auth/api/v1
50
50
  ```
51
51
 
@@ -0,0 +1,9 @@
1
+ huace_aigc_auth_client/__init__.py,sha256=fOPHwtUvYvLiHf8FNGOGDr1qhO5HShW9FQ_z598UOFQ,2332
2
+ huace_aigc_auth_client/legacy_adapter.py,sha256=6xrGJ6Wdw1EukGix3akRzzobZGtgbEEZH8jBoiV77IY,23250
3
+ huace_aigc_auth_client/sdk.py,sha256=ha1e_MSzLCsIMrdgcKSh-V5hTVR1rqqrIMWcDmtVMKs,23217
4
+ huace_aigc_auth_client/webhook.py,sha256=m-mjXNNqrUClrNpOHRBzty0XKFDBuZp4e_PgLd2t0aA,4070
5
+ huace_aigc_auth_client-1.1.8.dist-info/licenses/LICENSE,sha256=z7dgC7KljhBLNvKjN15391nMj3aLt0gbud8-Yf1F8EQ,1063
6
+ huace_aigc_auth_client-1.1.8.dist-info/METADATA,sha256=pV9rjwO5seSvQh77W5tz349kUvYMlVoqhQavRfBVO3Y,23485
7
+ huace_aigc_auth_client-1.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ huace_aigc_auth_client-1.1.8.dist-info/top_level.txt,sha256=kbv0nQ6PQ0JVneWPH7O2AbtlJnP7AjvFJ6JjM6ZEBxo,23
9
+ huace_aigc_auth_client-1.1.8.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- huace_aigc_auth_client/__init__.py,sha256=WIRO-YlPbw_hXU7WxmyEI2Be_BvatQijtlKTSlSrr4k,2332
2
- huace_aigc_auth_client/legacy_adapter.py,sha256=eNoyaCtTMdeNfzDlB66Fu-6WAfGYGk3DioIBAAZOL6A,21871
3
- huace_aigc_auth_client/sdk.py,sha256=ha1e_MSzLCsIMrdgcKSh-V5hTVR1rqqrIMWcDmtVMKs,23217
4
- huace_aigc_auth_client/webhook.py,sha256=m-mjXNNqrUClrNpOHRBzty0XKFDBuZp4e_PgLd2t0aA,4070
5
- huace_aigc_auth_client-1.1.7.dist-info/licenses/LICENSE,sha256=z7dgC7KljhBLNvKjN15391nMj3aLt0gbud8-Yf1F8EQ,1063
6
- huace_aigc_auth_client-1.1.7.dist-info/METADATA,sha256=UPpY9MyNjsxOSd4XWbGT89VMBGwGG8EOgrvBourbLlk,23486
7
- huace_aigc_auth_client-1.1.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
- huace_aigc_auth_client-1.1.7.dist-info/top_level.txt,sha256=kbv0nQ6PQ0JVneWPH7O2AbtlJnP7AjvFJ6JjM6ZEBxo,23
9
- huace_aigc_auth_client-1.1.7.dist-info/RECORD,,