feat: service key dependency generic

Dependency to verify service API key accepts the service_name from a RN generic, allowing for endpoints without a full RN to use it.
This commit is contained in:
Chris Milne 2026-06-16 16:09:17 +01:00
parent f96cb2112c
commit 154870acb1
3 changed files with 43 additions and 15 deletions

View file

@ -6,9 +6,36 @@ Models follow the nomenclature of:
- Models: "<Module><Method><Resource><Opt:Resource><Direction>" ie "ServiceGetServiceResponse"
"""
from pydantic import Field
from typing import Generic, TypeVar
from pydantic import Field, ConfigDict
from src.schemas import CustomBaseModel, ServiceIDMixin, ServiceSummary
from src.schemas import (
CustomBaseModel,
ServiceIDMixin,
ServiceSummary,
ServiceNameMixin,
)
T = TypeVar("T", bound=ServiceNameMixin)
class HasServiceName(CustomBaseModel, Generic[T]):
rn: T
class PermissionResponseSchema(CustomBaseModel):
model_config = ConfigDict(from_attributes=True, extra="ignore")
id: int
service_name: str
resource: str
action: str
class PermissionRequestSchema(CustomBaseModel):
resource: str
action: str
class ServiceWithKeySchema(ServiceSummary):