taolib.testing.oauth.services.admin_service#

OAuth 管理服务模块。

提供 OAuth 应用凭证管理和活动监控功能。

Classes#

OAuthAdminService

OAuth 管理服务。

Module Contents#

class taolib.testing.oauth.services.admin_service.OAuthAdminService(credential_repo: taolib.testing.oauth.repository.credential_repo.OAuthAppCredentialRepository, activity_repo: taolib.testing.oauth.repository.activity_repo.OAuthActivityLogRepository, connection_repo: taolib.testing.oauth.repository.connection_repo.OAuthConnectionRepository, token_encryptor: taolib.testing.oauth.crypto.token_encryption.TokenEncryptor)#

OAuth 管理服务。

提供凭证 CRUD、活动日志查询和连接统计功能。

参数:
  • credential_repo -- 凭证仓储

  • activity_repo -- 活动日志仓储

  • connection_repo -- 连接仓储

  • token_encryptor -- Token 加密器

_credential_repo#
_activity_repo#
_connection_repo#
_encryptor#
async create_credential(data: taolib.testing.oauth.models.credential.OAuthAppCredentialCreate, admin_user_id: str) taolib.testing.oauth.models.credential.OAuthAppCredentialResponse#

创建 OAuth 应用凭证。

参数:
  • data -- 凭证创建数据

  • admin_user_id -- 管理员用户 ID

返回:

凭证响应(不含 client_secret)

async update_credential(credential_id: str, data: taolib.testing.oauth.models.credential.OAuthAppCredentialUpdate, admin_user_id: str) taolib.testing.oauth.models.credential.OAuthAppCredentialResponse | None#

更新 OAuth 应用凭证。

参数:
  • credential_id -- 凭证 ID

  • data -- 凭证更新数据

  • admin_user_id -- 管理员用户 ID

返回:

更新后的凭证响应,不存在则返回 None

async delete_credential(credential_id: str, admin_user_id: str) bool#

删除 OAuth 应用凭证。

参数:
  • credential_id -- 凭证 ID

  • admin_user_id -- 管理员用户 ID

返回:

是否成功删除

async list_credentials() list[taolib.testing.oauth.models.credential.OAuthAppCredentialResponse]#

列出所有 OAuth 应用凭证。

返回:

凭证响应列表(不含 client_secret)

async get_activity_logs(*, user_id: str | None = None, provider: str | None = None, action: str | None = None, status: str | None = None, time_from: datetime.datetime | None = None, time_to: datetime.datetime | None = None, skip: int = 0, limit: int = 50) list[taolib.testing.oauth.models.activity.OAuthActivityLogResponse]#

查询活动日志。

参数:
  • user_id -- 按用户 ID 过滤

  • provider -- 按提供商过滤

  • action -- 按操作类型过滤

  • status -- 按状态过滤

  • time_from -- 起始时间

  • time_to -- 结束时间

  • skip -- 跳过记录数

  • limit -- 限制记录数

返回:

活动日志响应列表

async get_stats() dict[str, Any]#

获取 OAuth 连接和活动统计。

返回:

统计数据字典