feat(cloud-auth): enforce public scopes

This commit is contained in:
2026-07-12 17:56:14 +08:00
parent b916b394c7
commit 71f0a892e3
4 changed files with 113 additions and 17 deletions
+10
View File
@@ -6,11 +6,21 @@ from hmac import compare_digest
from typing import Protocol, runtime_checkable
TASKS_SUBMIT_SCOPE = "tasks:submit"
TASKS_READ_SCOPE = "tasks:read"
POOL_READ_SCOPE = "pool:read"
PLUGINS_READ_SCOPE = "plugins:read"
PLUGINS_ADMIN_SCOPE = "plugins:admin"
@dataclass(frozen=True)
class Principal:
id: str = "anonymous"
scopes: frozenset[str] = field(default_factory=frozenset)
def has_scope(self, scope: str) -> bool:
return "*" in self.scopes or scope in self.scopes
@runtime_checkable
class AuthProvider(Protocol):