taolib.testing.file_storage.services.access_service#

访问控制服务。

提供签名 URL 生成与验证、访问控制检查。

Classes#

AccessService

访问控制服务。

Module Contents#

class taolib.testing.file_storage.services.access_service.AccessService(file_repo: taolib.testing.file_storage.repository.file_repo.FileRepository, storage_backend: taolib.testing.file_storage.storage.protocols.StorageBackendProtocol, cdn_provider: taolib.testing.file_storage.cdn.protocols.CDNProviderProtocol | None = None, signed_url_secret: str = '')#

访问控制服务。

_file_repo#
_storage_backend#
_cdn_provider = None#
_secret = ''#
async generate_signed_url(file_id: str, expires_in: int = 3600, method: str = 'GET') str#

生成签名 URL。

generate_token(file_id: str, expires_in: int = 3600) dict[str, str | int]#

生成签名 token。

validate_token(file_id: str, expires: int, signature: str) bool#

验证签名 token。

async check_access(file_id: str, user_id: str | None = None, action: str = 'read') bool#

检查访问权限。