Add dynamic configuration #206

Merged
cmo merged 64 commits from dynamic-configuration into master 2026-06-12 10:47:49 +00:00

2026-06-12

Christian Monch
add test for unicode IRI handling
All checks were successful
Test execution / Test-all (push) Successful in 2m12s
2026-06-12 12:41:54 +02:00
Christian Monch
2026-06-12 12:41:54 +02:00
Christian Monch
2026-06-12 12:41:54 +02:00
Christian Monch
addapt dump-things-pid-check to the new structure
Adapt the code of `dump-things-pid-check` to the dynamic
configuration changes.
2026-06-12 12:41:54 +02:00
Christian Monch
ensure that record-dir config files are created
If a record-dir backend is created on a directory,
check if the config file exists, if not write it.
2026-06-12 12:41:54 +02:00
Christian Monch
2026-06-12 12:41:54 +02:00
Christian Monch
2026-06-12 12:41:54 +02:00
Christian Monch
add compatibility check for git audit directories
Add code to check whether the directory specified
int the git-audit configuration is either non-existing,
empty, or compatible with git-audit.
2026-06-12 12:41:54 +02:00
Christian Monch
replace schema-attribute in pydantic-objects
Replaces the `schema`-attribute with the
attribute `schema_location`. That prevents
shadowing of pydantic's internal `schema`-attribute
and gets rid of pydantic-issues warnings.
2026-06-12 12:41:54 +02:00
Christian Monch
return admin_token in test fixture
The test-fixture `fast_api_simple` now
returns a tuple containing:

- test_client instance
- store path
- admin token
2026-06-12 12:41:54 +02:00
Christian Monch
improve incoming-path verification
Verify that incoming paths exist when a collection
is created a token has write-access to the
collection. Checks that incoming-label is set
for the token.

Add tests for incoming path validation.
2026-06-12 12:41:54 +02:00
Christian Monch
handle configuration file structure failures
Do not allow unknown keys in configuration files.
Add a test for structure error detection.
2026-06-12 12:41:54 +02:00
Christian Monch
add test for config file error detection
Test that errors in the format of the configuration
file are caught and converted to `ConfigError`.
2026-06-12 12:41:54 +02:00
Christian Monch
improve configuration processing
Add scanner error detection to configuration loading. Raise
an error if the configuration YAML-file cannot be loaded.

Detect and reject token definitions with write permissions
and without incoming-labels or write access for
collections that do not define an incoming directory.

Rename `get_permissions` to `get_token_permissions`
2026-06-12 12:41:54 +02:00
Christian Monch
fix default token name setting in config conversion
Use the correct token names, when converting version 1
configuration files to version 2 configuration files.
2026-06-12 12:41:54 +02:00
Christian Monch
2026-06-12 12:41:54 +02:00
Christian Monch
add --admin-token-hash, remove --admin-token
This commit removes the option `--admin-token` and
adds the option `--admin-token-hash`, which accepts
a hashed token (sha256 in 64-digits hex representation).
2026-06-12 12:41:54 +02:00
Christian Monch
2026-06-12 12:41:54 +02:00
Christian Monch
add collection configuration checks
Check the following two conditions when
new collections are created:

1. the name of the collection is not a
   reserved name.

2. collections do not share incoming or
   curated directories with other collections.
   This is done to prevent data leaks, which
   could happen when different collections
   share directories.
2026-06-12 12:41:54 +02:00
Christian Mönch
fix tests
Remove schema-definitions from sqlite-backend configuration.
Use empty dicitionary as default for Configuration.admin_tokens.
2026-06-12 12:41:54 +02:00
Christian Monch
add the dump-things-load-config command
Add a command that interprets configuration
files and creates the objects defined in the
configuration file in a service.

This command can be used to migrate from
old dump-things server to new dump-things
server, when the option --old-format is used.

Note that there are a few differences
between the old and the new format:

1. Keys in `tokens` are now token names,
   that map to token configurations.

2. Token configurations now contain the
   additional attributes `representation`
   and `hashed`.

3. `schema` is now an attribute of a
   collection. It is removed from
   sqlite backend configurations.
2026-06-12 12:41:54 +02:00
Christian Monch
2026-06-12 12:41:54 +02:00
Christian Monch
cleanup code
Update format, remove unused code and debug code
2026-06-12 12:41:54 +02:00
Christian Monch
2026-06-12 12:41:54 +02:00
Christian Monch
clean up backend code
Format backend code, add __all__ variables.
2026-06-12 12:41:54 +02:00
Christian Monch
2026-06-12 12:41:54 +02:00
Christian Monch
use hashed admin token representations
When adding the plain admin token `t` via
`/admin_tokens`, `AdminTokenRequest.representation`
must contain `hash_token_representation(t)`.

The value of `AdminTokenRequest.representation`
is checked for the correct pattern (a 40-digit hex
number) and stored verbatim in the configuration.

To authenticate an administrator, the token
provided in the `x-dumpthings-token`-header is
hashed and compared to the stored values of
`AdminTokenRequest.representation`.
2026-06-12 12:41:54 +02:00
Christian Monch
adapt collection- and token-managing tests
Test that endpoints of deleted collections are
removed from the openapi documentation and
generate 404-errors when accessed.

Adapt token listing test to the modified token
result structure, which does not contain the
token representation anymore.
2026-06-12 12:41:54 +02:00
Christian Monch
hash admin-token representation by default
By default the admin-token representation is hashed.
That means the request should contain the plain token,
unless the request-attribute `hashed` is set. In this
case, the `POST /admin-tokens` endpoint assumes that
the representation is already hashed. It will perform
a simple syntax verification to assure that the
representation is a 40-digit hex number.
2026-06-12 12:41:54 +02:00
Christian Monch
ensure that api-doc tags are deleted
When a collection is deleted, the collection
specific openapi doc tags are deleted as well.
2026-06-12 12:41:54 +02:00
Christian Monch
add tag_info generation
Ensure that generated endpoints are tagged
and sorted correctly in the openapi docs.
2026-06-12 12:41:54 +02:00
Christian Monch
add explicit admin-token endpoints
Handle admin tokens seperately from the
traditional token handling
2026-06-12 12:41:11 +02:00