dump-things-service/dump_things_service/__init__.py
Christian Monch 1d1a70fbd5 feat: add policy handling
To support exact specification of user-IDs,
`AuthenticationInfo` now contains a
`source_identifier`. This will identify the
authentication source that was used. All
`AuthenticationSource`s are instantiated with
a `source_identifier`, chosen by the caller.

Add user-id -> policy mapping to collection
configuration

Adapt code to extended user ID information, i.e. to
(authentication_instance_id, user_id),

feat: add policy handling to SQLite backend

This commit implements policy handling in the
SQLite backend. That means, result records
are filtered by an optional default policy, a
set of active policies, and the policies that
are set in the annotations of a record.
2026-10-01 22:19:10 +02:00

66 lines
1.5 KiB
Python

from enum import Enum
from typing import Any
from starlette.status import (
HTTP_200_OK,
HTTP_201_CREATED,
HTTP_300_MULTIPLE_CHOICES,
HTTP_400_BAD_REQUEST,
HTTP_401_UNAUTHORIZED,
HTTP_403_FORBIDDEN,
HTTP_404_NOT_FOUND,
HTTP_406_NOT_ACCEPTABLE,
HTTP_409_CONFLICT,
HTTP_413_CONTENT_TOO_LARGE,
HTTP_422_UNPROCESSABLE_CONTENT,
HTTP_500_INTERNAL_SERVER_ERROR,
HTTP_503_SERVICE_UNAVAILABLE,
)
from dump_things_service._version import __version__
__all__ = [
'HTTP_200_OK',
'HTTP_201_CREATED',
'HTTP_300_MULTIPLE_CHOICES',
'HTTP_400_BAD_REQUEST',
'HTTP_401_UNAUTHORIZED',
'HTTP_403_FORBIDDEN',
'HTTP_404_NOT_FOUND',
'HTTP_406_NOT_ACCEPTABLE',
'HTTP_409_CONFLICT',
'HTTP_413_CONTENT_TOO_LARGE',
'HTTP_422_UNPROCESSABLE_CONTENT',
'HTTP_500_INTERNAL_SERVER_ERROR',
'HTTP_503_SERVICE_UNAVAILABLE',
'JSON',
'YAML',
'Format',
'__version__',
'config_file_name',
'dump_things_private_collection_name',
'reserved_collection_names',
]
class Format(str, Enum):
json = 'json'
ttl = 'ttl'
JSON = dict[str, Any] | list[Any] | str | int | float | None
YAML = JSON
config_file_name = '.dumpthings.yaml'
dump_things_private_collection_name = '__dump_things__'
reserved_collection_names = (
'collections',
'tokens',
'admin_tokens',
'api',
dump_things_private_collection_name,
)
policy_annotation = 'https://example.org/dumpthings/policy_set'