huace-aigc-auth-client 1.1.7__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.
@@ -0,0 +1,101 @@
1
+ """
2
+ AIGC Auth Python SDK
3
+
4
+ 使用方法:
5
+ from sdk import AigcAuthClient, require_auth
6
+
7
+ # 创建客户端
8
+ client = AigcAuthClient(app_id="your_app_id", app_secret="your_app_secret")
9
+
10
+ # 验证 token
11
+ result = client.verify_token(token)
12
+
13
+ # 获取用户信息
14
+ user_info = client.get_user_info(token)
15
+
16
+ # FastAPI 中间件使用
17
+ @app.get("/protected")
18
+ @require_auth(client)
19
+ def protected_route(user_info: dict):
20
+ return {"user": user_info}
21
+
22
+ 旧系统接入:
23
+ from sdk import AigcAuthClient
24
+ from sdk.legacy_adapter import (
25
+ LegacySystemAdapter,
26
+ SyncConfig,
27
+ UserSyncService,
28
+ FieldMapping,
29
+ create_sync_config,
30
+ create_default_field_mappings
31
+ )
32
+
33
+ # 创建自定义字段映射(根据接入系统的用户表定制)
34
+ field_mappings = create_default_field_mappings()
35
+ # 或自定义: field_mappings = [FieldMapping(...), ...]
36
+
37
+ sync_config = create_sync_config(
38
+ field_mappings=field_mappings,
39
+ webhook_url="https://your-domain.com/webhook"
40
+ )
41
+
42
+ # 实现适配器并创建同步服务
43
+ adapter = YourLegacyAdapter(sync_config)
44
+ sync_service = UserSyncService(client, adapter)
45
+ """
46
+
47
+ from .sdk import (
48
+ AigcAuthClient,
49
+ require_auth,
50
+ AuthMiddleware,
51
+ UserInfo,
52
+ TokenVerifyResult,
53
+ AigcAuthError,
54
+ create_fastapi_auth_dependency
55
+ )
56
+
57
+ from .legacy_adapter import (
58
+ LegacySystemAdapter,
59
+ LegacyUserData,
60
+ SyncConfig,
61
+ SyncDirection,
62
+ PasswordMode,
63
+ FieldMapping,
64
+ UserSyncService,
65
+ WebhookSender,
66
+ SyncResult,
67
+ create_sync_config,
68
+ create_default_field_mappings,
69
+ )
70
+
71
+ from .webhook import (
72
+ register_webhook_router,
73
+ verify_webhook_signature,
74
+ )
75
+
76
+ __all__ = [
77
+ # 核心类
78
+ "AigcAuthClient",
79
+ "require_auth",
80
+ "AuthMiddleware",
81
+ "UserInfo",
82
+ "TokenVerifyResult",
83
+ "AigcAuthError",
84
+ "create_fastapi_auth_dependency",
85
+ # 旧系统接入
86
+ "LegacySystemAdapter",
87
+ "LegacyUserData",
88
+ "SyncConfig",
89
+ "SyncDirection",
90
+ "PasswordMode",
91
+ "FieldMapping",
92
+ "UserSyncService",
93
+ "WebhookSender",
94
+ "SyncResult",
95
+ "create_sync_config",
96
+ "create_default_field_mappings",
97
+ # Webhook 接收
98
+ "register_webhook_router",
99
+ "verify_webhook_signature",
100
+ ]
101
+ __version__ = "1.1.7"