PluginSQL renamed to PermissionSQL, closes #2524

This commit is contained in:
Simon Willison 2025-10-23 09:34:19 -07:00
commit 5ed57607e5
11 changed files with 84 additions and 81 deletions

View file

@ -1,6 +1,6 @@
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Optional, NamedTuple
from typing import Any, Dict, Optional, NamedTuple
class Resource(ABC):
@ -86,6 +86,21 @@ class Action:
resource_class: type[Resource]
@dataclass
class PermissionSQL:
"""
A plugin contributes SQL that yields:
parent TEXT NULL,
child TEXT NULL,
allow INTEGER, -- 1 allow, 0 deny
reason TEXT
"""
source: str # identifier used for auditing (e.g., plugin name)
sql: str # SQL that SELECTs the 4 columns above
params: Dict[str, Any] # bound params for the SQL (values only; no ':' prefix)
# This is obsolete, replaced by Action and ResourceType
@dataclass
class Permission: