Read policies from an external file and add a reload trigger endpoint. #274

Merged
cmo merged 4 commits from external-mapping into master 2026-10-02 12:03:13 +00:00

2026-10-02

Christian Monch
refactor: reformat code, remove unused imports
Some checks failed
Codespell / Check for spelling errors (push) Failing after 43s
Codespell / Check for spelling errors (pull_request) Failing after 49s
Ruff / Code linting (pull_request) Successful in 52s
Ruff / Code linting (push) Successful in 57s
Type annotation (PR) / check (pull_request) Failing after 1m11s
Test execution / Test-all (push) Successful in 1m26s
2026-10-02 13:58:27 +02:00
Christian Monch
doc: update documentation on policies
Some checks failed
Codespell / Check for spelling errors (push) Failing after 28s
Ruff / Code linting (push) Failing after 34s
Test execution / Test-all (push) Successful in 1m13s
Codespell / Check for spelling errors (pull_request) Failing after 27s
Ruff / Code linting (pull_request) Failing after 33s
Type annotation (PR) / check (pull_request) Has been cancelled
Describe the policy reference mechanism, the
structure of a policy information file and
the policy reload endpoint.
2026-10-02 13:49:23 +02:00
Christian Monch
refactor: return an empty body when reloading policies
Some checks failed
Codespell / Check for spelling errors (push) Failing after 27s
Ruff / Code linting (push) Failing after 35s
Test execution / Test-all (push) Successful in 1m13s
2026-10-02 13:30:46 +02:00
Christian Monch
feat: move policy info out of configuration
This commit removes the configuration keys:

- default_policy
- policy_annotation_tag
- policy_mapping

and adds the key:

- policy_info_location

The key `policy_info_location` optionally contain
a URL from which policy information is read.

The commit also adds the endpoint

GET /management/reload/policy_info/{collection}

The endpoint allows to reload policy information
from either the configured location of from a
location given in the query-parameter `url`.

The endpoint requires a CURATOR-token.

Policy information is a JSON-representation
of a `dump-things-service.abstract_config.PolicyInfo`
object. For example:

{
  "default_policy": "abc:policy_abc",
  "policy_annotation_tag": "https://example.org/dumpthings/policy_set",
  "policy_mapping": [
    {
      "auth_source": "config",
      "user_id": "user_all",
      "authorized_by": [
        "abc:policy_abc",
        "policy_1"
      ]
    },
    {
      "auth_source": "some_other_source",
      "user_id": "test_user_2",
      "authorized_by": [
        "https://examples.com/policy_example_2",
        "abc:policy_def"
      ]
    }
  ]
}
2026-10-02 13:30:43 +02:00