fix(api): validate api key prefix

This commit is contained in:
huanghuoguoguo
2026-05-16 11:03:17 +08:00
parent b251fc4b89
commit 31f4bc1ad6
2 changed files with 43 additions and 0 deletions
@@ -52,6 +52,9 @@ class ApiKeyService:
async def verify_api_key(self, key: str) -> bool:
"""Verify if an API key is valid"""
if not isinstance(key, str) or not key.startswith('lbk_'):
return False
result = await self.ap.persistence_mgr.execute_async(
sqlalchemy.select(apikey.ApiKey).where(apikey.ApiKey.key == key)
)