Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d6caf8a9e | ||
|
|
2bd7487ba7 | ||
|
|
29a9aea3b1 | ||
|
|
b5f431c766 | ||
|
|
5753488375 |
@@ -130,3 +130,18 @@ bounded outcome counts in audit evidence.
|
||||
The shared core WebUI helper `PolicySourcePath` renders the source path shape
|
||||
for module UIs. Modules may use their own field layout, but the data contract
|
||||
should remain this shape.
|
||||
# Function assignment delegation and escalation
|
||||
|
||||
The `policy.functionAssignmentGovernance` decision includes the effective
|
||||
`delegation_allowed`, `maximum_delegation_depth`, and
|
||||
`maximum_delegated_validity_days` values plus zero or more per-step escalation
|
||||
rules. Each rule binds `holder`, `authority`, or `recipient` review to one exact
|
||||
target function and a bounded timeout. Consumers must treat the decision as a
|
||||
current limit, not a captured grant: IDM rechecks it across the complete source
|
||||
chain at every consequential transition.
|
||||
|
||||
An elapsed timeout does not change the approval result. IDM records an explicit
|
||||
escalated state and the target function; Policy authorizes only a current holder
|
||||
of that target for the escalated decision. Missing, malformed, vacant, expired,
|
||||
cyclic, over-depth, or tightened routes fail closed with their reason preserved
|
||||
in the decision and transition evidence.
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@govoplan/policy-webui",
|
||||
"version": "0.1.18",
|
||||
"version": "0.1.23",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "webui/src/index.ts",
|
||||
@@ -18,7 +18,7 @@
|
||||
"LICENSE"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@govoplan/core-webui": "^0.1.18",
|
||||
"@govoplan/core-webui": "^0.1.45",
|
||||
"lucide-react": "^1.23.0",
|
||||
"react": ">=19.2.7 <20",
|
||||
"react-dom": ">=19.2.7 <20",
|
||||
|
||||
+2
-2
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "govoplan-policy"
|
||||
version = "0.1.19"
|
||||
version = "0.1.23"
|
||||
description = "GovOPlaN policy platform module."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
authors = [{ name = "GovOPlaN" }]
|
||||
dependencies = [
|
||||
"govoplan-core>=0.1.20",
|
||||
"govoplan-core>=0.1.45",
|
||||
]
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
|
||||
@@ -204,6 +204,9 @@ def write_campaign_archive_encryption_policy(
|
||||
owner_type=owner_type,
|
||||
owner_id=owner_id,
|
||||
)
|
||||
# Saving updates the same ORM row held by ``before``. Capture its
|
||||
# value now so history/rollback does not silently record the new policy.
|
||||
before_policy = dict(before.row.policy) if before.row else {}
|
||||
if clean_scope == "system":
|
||||
approval = ensure_configuration_change_allowed(
|
||||
session,
|
||||
@@ -230,7 +233,7 @@ def write_campaign_archive_encryption_policy(
|
||||
record_configuration_change_applied(
|
||||
session,
|
||||
key="campaign_archive_encryption_policy",
|
||||
before_value=(dict(before.row.policy) if before.row else {}),
|
||||
before_value=before_policy,
|
||||
after_value=policy_value,
|
||||
actor_user_id=principal.user.id,
|
||||
approval=approval,
|
||||
|
||||
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
from collections.abc import Mapping
|
||||
|
||||
from govoplan_core.core.policy import (
|
||||
FunctionAssignmentEscalationRule,
|
||||
FunctionAssignmentGovernanceDecision,
|
||||
FunctionAssignmentGovernanceRequest,
|
||||
PolicySourceStep,
|
||||
@@ -50,6 +51,25 @@ class FunctionAssignmentGovernancePolicyProvider:
|
||||
),
|
||||
)
|
||||
authority_function_id = _text(policy.get("authority_function_id"))
|
||||
delegation_allowed = _bool(
|
||||
policy.get("delegation_allowed"),
|
||||
default=False,
|
||||
)
|
||||
maximum_delegation_depth = (
|
||||
_bounded_int(
|
||||
policy.get("maximum_delegation_depth"),
|
||||
default=1,
|
||||
minimum=1,
|
||||
maximum=20,
|
||||
)
|
||||
if delegation_allowed
|
||||
else 0
|
||||
)
|
||||
maximum_delegated_validity_days = _optional_positive_int(
|
||||
policy.get("maximum_delegated_validity_days"),
|
||||
maximum=3650,
|
||||
)
|
||||
escalation_rules, escalation_requirements = _escalation_rules(policy)
|
||||
requirements: list[str] = []
|
||||
if "authority" in required_steps and authority_function_id is None:
|
||||
requirements.append("authority_function")
|
||||
@@ -59,6 +79,7 @@ class FunctionAssignmentGovernancePolicyProvider:
|
||||
)
|
||||
if evidence_required and not request.context.get("has_evidence"):
|
||||
requirements.append("evidence")
|
||||
requirements.extend(escalation_requirements)
|
||||
allowed, reason = _action_decision(
|
||||
request,
|
||||
profile=profile,
|
||||
@@ -79,6 +100,10 @@ class FunctionAssignmentGovernancePolicyProvider:
|
||||
required_steps=required_steps,
|
||||
authority_function_id=authority_function_id,
|
||||
evidence_required=evidence_required,
|
||||
delegation_allowed=delegation_allowed,
|
||||
maximum_delegation_depth=maximum_delegation_depth,
|
||||
maximum_delegated_validity_days=maximum_delegated_validity_days,
|
||||
escalation_rules=escalation_rules,
|
||||
requirements=tuple(requirements),
|
||||
)
|
||||
|
||||
@@ -106,19 +131,44 @@ def _action_decision(
|
||||
return True, None
|
||||
if profile == "authority_only":
|
||||
allowed = bool(context.get("actor_is_authority"))
|
||||
reason = "Only the designated authority may initiate this grant."
|
||||
reason = _route_reason(
|
||||
context,
|
||||
"authority",
|
||||
"Only the designated authority may initiate this grant.",
|
||||
)
|
||||
else:
|
||||
allowed = bool(context.get("actor_is_holder"))
|
||||
reason = "An effective function holder must initiate this grant."
|
||||
reason = _route_reason(
|
||||
context,
|
||||
"holder",
|
||||
"An effective function holder must initiate this grant.",
|
||||
)
|
||||
return allowed, None if allowed else reason
|
||||
if action == "approve_holder":
|
||||
allowed = "holder" in required_steps and bool(context.get("actor_is_holder"))
|
||||
return allowed, None if allowed else "A current holder must approve."
|
||||
return allowed, None if allowed else _route_reason(
|
||||
context,
|
||||
"holder",
|
||||
"A current holder must approve.",
|
||||
)
|
||||
if action == "approve_authority":
|
||||
allowed = "authority" in required_steps and bool(
|
||||
context.get("actor_is_authority")
|
||||
)
|
||||
return allowed, None if allowed else "The designated authority must approve."
|
||||
return allowed, None if allowed else _route_reason(
|
||||
context,
|
||||
"authority",
|
||||
"The designated authority must approve.",
|
||||
)
|
||||
if action == "approve_escalation":
|
||||
allowed = request.current_state == "escalated" and bool(
|
||||
context.get("actor_is_escalation_target")
|
||||
)
|
||||
return allowed, None if allowed else _route_reason(
|
||||
context,
|
||||
"escalation",
|
||||
"A current holder of the explicit escalation target must approve.",
|
||||
)
|
||||
if action == "accept_recipient":
|
||||
allowed = "recipient" in required_steps and bool(
|
||||
context.get("candidate_is_actor")
|
||||
@@ -134,6 +184,13 @@ def _action_decision(
|
||||
elif request.current_state == "awaiting_recipient":
|
||||
allowed = bool(context.get("candidate_is_actor"))
|
||||
reason = "Only the candidate may act at recipient acceptance."
|
||||
elif request.current_state == "escalated":
|
||||
allowed = bool(context.get("actor_is_escalation_target"))
|
||||
reason = _route_reason(
|
||||
context,
|
||||
"escalation",
|
||||
"Only a current holder of the explicit escalation target may act.",
|
||||
)
|
||||
else:
|
||||
allowed = False
|
||||
reason = "The current state does not accept this review action."
|
||||
@@ -196,6 +253,10 @@ def _decision(
|
||||
required_steps: tuple[str, ...] = (),
|
||||
authority_function_id: str | None = None,
|
||||
evidence_required: bool = False,
|
||||
delegation_allowed: bool = False,
|
||||
maximum_delegation_depth: int = 0,
|
||||
maximum_delegated_validity_days: int | None = None,
|
||||
escalation_rules: tuple[FunctionAssignmentEscalationRule, ...] = (),
|
||||
requirements: tuple[str, ...] = (),
|
||||
) -> FunctionAssignmentGovernanceDecision:
|
||||
recipient_required = "recipient" in required_steps
|
||||
@@ -216,6 +277,10 @@ def _decision(
|
||||
policy.get("maximum_validity_days"),
|
||||
maximum=3650,
|
||||
),
|
||||
delegation_allowed=delegation_allowed,
|
||||
maximum_delegation_depth=maximum_delegation_depth,
|
||||
maximum_delegated_validity_days=maximum_delegated_validity_days,
|
||||
escalation_rules=escalation_rules,
|
||||
request_expiry_hours=_bounded_int(
|
||||
policy.get("request_expiry_hours"),
|
||||
default=336,
|
||||
@@ -236,6 +301,7 @@ def _decision(
|
||||
"function_id": request.function_id,
|
||||
"kind": request.kind,
|
||||
"action": request.action,
|
||||
"actor_routes": dict(request.context.get("actor_routes") or {}),
|
||||
},
|
||||
)
|
||||
|
||||
@@ -250,6 +316,9 @@ def _requirements_reason(requirements: list[str]) -> str:
|
||||
"authority_function": "a designated authority function",
|
||||
"evidence": "the required evidence",
|
||||
"valid_profile": "a supported governance profile",
|
||||
"escalation_holder": "a valid holder-step escalation rule",
|
||||
"escalation_authority": "a valid authority-step escalation rule",
|
||||
"escalation_recipient": "a valid recipient-step escalation rule",
|
||||
}
|
||||
return (
|
||||
"Submission requires "
|
||||
@@ -258,6 +327,55 @@ def _requirements_reason(requirements: list[str]) -> str:
|
||||
)
|
||||
|
||||
|
||||
def _escalation_rules(
|
||||
policy: Mapping[str, object],
|
||||
) -> tuple[tuple[FunctionAssignmentEscalationRule, ...], list[str]]:
|
||||
raw = policy.get("escalation")
|
||||
if raw is None:
|
||||
return (), []
|
||||
if not isinstance(raw, Mapping):
|
||||
return (), ["escalation_holder"]
|
||||
rules: list[FunctionAssignmentEscalationRule] = []
|
||||
requirements: list[str] = []
|
||||
for step in ("holder", "authority", "recipient"):
|
||||
value = raw.get(step)
|
||||
if value is None:
|
||||
continue
|
||||
if not isinstance(value, Mapping):
|
||||
requirements.append(f"escalation_{step}")
|
||||
continue
|
||||
target_function_id = _text(value.get("target_function_id"))
|
||||
timeout_hours = _optional_positive_int(
|
||||
value.get("timeout_hours"),
|
||||
maximum=8760,
|
||||
)
|
||||
if target_function_id is None or timeout_hours is None:
|
||||
requirements.append(f"escalation_{step}")
|
||||
continue
|
||||
rules.append(
|
||||
FunctionAssignmentEscalationRule(
|
||||
step=step, # type: ignore[arg-type]
|
||||
target_function_id=target_function_id,
|
||||
timeout_hours=timeout_hours,
|
||||
)
|
||||
)
|
||||
return tuple(rules), requirements
|
||||
|
||||
|
||||
def _route_reason(
|
||||
context: Mapping[str, object],
|
||||
route: str,
|
||||
fallback: str,
|
||||
) -> str:
|
||||
routes = context.get("actor_routes")
|
||||
if not isinstance(routes, Mapping):
|
||||
return fallback
|
||||
value = routes.get(route)
|
||||
if not isinstance(value, Mapping):
|
||||
return fallback
|
||||
return _text(value.get("reason")) or fallback
|
||||
|
||||
|
||||
def _has_scope(
|
||||
request: FunctionAssignmentGovernanceRequest,
|
||||
scope: str,
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
"""German translations for public structured documentation metadata."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
|
||||
GERMAN_STRUCTURED_TRANSLATIONS: dict[str, dict[str, Any]] = {'policy.data-subject-requests': {'consequence_classes': {'export_policy_attribution': 'Returns '
|
||||
'minimiert '
|
||||
'Politik '
|
||||
'Aktivität '
|
||||
'für das '
|
||||
'genaue '
|
||||
'Konto.',
|
||||
'retain_policy_evidence': 'Bewahrt die '
|
||||
'politische '
|
||||
'Governance-Rechenschaftspflicht.'}},
|
||||
'policy.function-assignment-delegation-escalation': {'fields': [{'consequence': 'Erlaubt nur dann '
|
||||
'geregelte '
|
||||
'abgeleitete '
|
||||
'Zuweisungen, '
|
||||
'wenn '
|
||||
'Organisationen '
|
||||
'auch die '
|
||||
'Funktion '
|
||||
'delegierbar '
|
||||
'markieren.',
|
||||
'key': 'delegation_allowed'},
|
||||
{'consequence': 'Lehnt längere '
|
||||
'aktuelle Ketten '
|
||||
'ab, '
|
||||
'einschließlich '
|
||||
'Ketten, die vor '
|
||||
'einem engeren '
|
||||
'Limit akzeptiert '
|
||||
'wurden.',
|
||||
'key': 'maximum_delegation_depth'},
|
||||
{'consequence': 'Caps jedes '
|
||||
'delegierte '
|
||||
'Gültigkeitsfenster '
|
||||
'zusätzlich zu '
|
||||
'seinem '
|
||||
'Quellfenster.',
|
||||
'key': 'maximum_delegated_validity_days'},
|
||||
{'consequence': 'Pins eine '
|
||||
'Zielfunktion und '
|
||||
'Frist ohne '
|
||||
'Erteilung oder '
|
||||
'Ersatz '
|
||||
'Genehmigung.',
|
||||
'key': 'escalation.<step>'}]},
|
||||
'policy.hierarchy-overrides-and-retention': {'outcome': 'Der ausgewählte Berechtigungsumfang hat '
|
||||
'eine erklärbare Aufbewahrungsrichtlinie '
|
||||
'und jeder destruktiven Anwendung wird '
|
||||
'eine Dry-Run-Überprüfung vorausgegangen.',
|
||||
'prerequisites': ['Policy und Access sind aktiviert.',
|
||||
'Die handelnde Person kann die '
|
||||
'Richtlinieneinstellungen am '
|
||||
'ausgewählten Bereich lesen.'],
|
||||
'steps': ['Überprüfen Sie den effektiven Wert und '
|
||||
'seinen Policy Source Path.',
|
||||
'Schmale nur Felder, die die übergeordnete '
|
||||
'Richtlinie diesen Bereich außer Kraft '
|
||||
'setzt.',
|
||||
'Speichern Sie die Richtlinie und führen '
|
||||
'Sie dann einen System-Dry-Run aus, bevor '
|
||||
'Sie die Retention anwenden.',
|
||||
'Überprüfen Sie das Bounded Outcome und '
|
||||
'prüfen Sie den Nachweis nach einem '
|
||||
'angewandten Durchlauf.'],
|
||||
'verification': 'Laden Sie die Richtlinie neu, '
|
||||
'bestätigen Sie ihren Quellpfad und '
|
||||
'vergleichen Sie die Trockenlauf- '
|
||||
'oder angewandte Ergebnistabelle mit '
|
||||
'den Prüfungsnachweisen.'},
|
||||
'policy.impact-preview': {'limitations': ['Nicht verfügbare optionale Anbieter werden erklärt und '
|
||||
'niemals als Null-Auswirkungen behandelt.',
|
||||
'Ressourcendetails werden ohne policy:impact:details '
|
||||
'ausgeblendet.'],
|
||||
'steps': ['Wählen Sie eine explizite Impact-Provider-Population und ein '
|
||||
'begrenztes Limit.',
|
||||
'Preview und Inspect Outcome Counts, Coverage State und '
|
||||
'Provenienz.',
|
||||
'Reauthentifizieren, wenn eine systemweite Änderung als hohe '
|
||||
'Auswirkungen eingestuft wird.',
|
||||
'Speichern Sie erst, nachdem die Vorschau mit dem aktuellen '
|
||||
'Dirty Draft übereinstimmt.']},
|
||||
'policy.retention-execution-and-recovery': {'limitations': ['Die Anwendung kann gelöschte EML- '
|
||||
'oder Mock-Mailbox-Inhalte nicht '
|
||||
'wiederherstellen.',
|
||||
'Ein Trockenlauf ist eine Vorschau '
|
||||
'und reserviert den gemeldeten Satz '
|
||||
'nicht gegen gleichzeitige '
|
||||
'Änderungen.'],
|
||||
'outcome': 'Förderfähige Details werden redigiert und '
|
||||
'förderfähige generierte Artefakte werden '
|
||||
'mit begrenztem Ergebnis und '
|
||||
'Prüfungsnachweis gelöscht.',
|
||||
'prerequisites': ['Die handelnde Person kann '
|
||||
'Systemeinstellungen schreiben.',
|
||||
'Die vorgesehene '
|
||||
'Systemaufbewahrungsrichtlinie wird '
|
||||
'gespeichert und neu geladen.',
|
||||
'Recovery Evidenz ist aktuell für '
|
||||
'generierte Artefakte.'],
|
||||
'steps': ['Führen Sie einen Trockenlauf durch und '
|
||||
'überprüfen Sie jede Datenklasse und '
|
||||
'Ergebniszahl.',
|
||||
'Stoppen Sie, wenn Anbieter ausfallen, die '
|
||||
'Wiederherstellung blockiert wird oder '
|
||||
'Zählungen unerwartet sind.',
|
||||
'Bestätigen Sie den destruktiven Lauf erst '
|
||||
'nach einer Überprüfung der Politik und der '
|
||||
'Wiederherstellung.',
|
||||
'Vergleichen Sie das angewandte Ergebnis '
|
||||
'mit den Prüfungsnachweisen.'],
|
||||
'verification': 'Überprüfen Sie das neueste Ergebnis, '
|
||||
'die Fehler- und '
|
||||
'Wiederherstellungszahlen des '
|
||||
'Anbieters und suchen Sie dann den '
|
||||
'Auditdatensatz retention '
|
||||
'policy.run.'}}
|
||||
@@ -1,5 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from govoplan_core.core.modules import with_documentation_structured_translations
|
||||
from govoplan_policy.backend.german_structured_documentation import GERMAN_STRUCTURED_TRANSLATIONS
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from govoplan_core.core.access import (
|
||||
@@ -25,6 +28,7 @@ from govoplan_core.core.policy import (
|
||||
)
|
||||
from govoplan_core.core.modules import (
|
||||
CapabilityDocumentation,
|
||||
DocumentationLink,
|
||||
DocumentationTopic,
|
||||
FrontendModule,
|
||||
MigrationSpec,
|
||||
@@ -150,7 +154,7 @@ POLICY_IMPACT_DETAILS_SCOPE = "policy:impact:details"
|
||||
manifest = ModuleManifest(
|
||||
id="policy",
|
||||
name="Policy",
|
||||
version="0.1.19",
|
||||
version="0.1.23",
|
||||
permissions=(
|
||||
PermissionDefinition(
|
||||
scope=ACCESS_EXPLANATION_SUBJECT_SCOPE,
|
||||
@@ -230,6 +234,25 @@ manifest = ModuleManifest(
|
||||
documentation_types=("admin", "user"),
|
||||
audience=("policy_admin", "data_steward", "auditor"),
|
||||
related_modules=("datasources", "access", "audit"),
|
||||
translations={
|
||||
"de": {
|
||||
"title": "Richtlinienebenen für die Sichtbarkeit von Datenquellen",
|
||||
"summary": (
|
||||
"Die von Datasources verwaltete Sichtbarkeit für ACLs, Felder und Zeilen durch referenzierte hierarchische "
|
||||
"Richtlinien weiter einschränken."
|
||||
),
|
||||
"body": (
|
||||
"Datasources besitzt die Durchsetzung und eine lokale Sichtbarkeitsgrundlage. Policy kann für das globale Ziel und "
|
||||
"einen ausdrücklich referenzierten Richtlinienschlüssel zusätzliche Ebenen auf System-, Mandanten-, Gruppen- oder "
|
||||
"Benutzerebene liefern. Jede passende Ebene wirkt als weitere Einschränkung und kann keine Quelle, kein Feld und keine "
|
||||
"Zeile wiederherstellen, die eine andere Ebene entfernt hat. Eine nicht auflösbare Referenz, fehlerhafte Nutzdaten oder "
|
||||
"eine nicht verfügbare Entscheidung schließen den Zugriff sicher. Entscheidungsnachweise enthalten Richtlinienkennungen, "
|
||||
"Geltungsbereiche, Revisionen und einen stabilen Hash, aber niemals Zeilen- oder Feldwerte, Connector-Endpunkte oder "
|
||||
"Zugangsdaten. Ist Policy nicht installiert und keine externe Richtlinienreferenz konfiguriert, setzt Datasources seine "
|
||||
"lokalen Regeln für Umfang, ACL, Projektion, Schwärzung und Zeilenfilterung weiterhin durch."
|
||||
),
|
||||
}
|
||||
},
|
||||
order=28,
|
||||
),
|
||||
DocumentationTopic(
|
||||
@@ -253,6 +276,23 @@ manifest = ModuleManifest(
|
||||
documentation_types=("admin", "user"),
|
||||
audience=("user", "policy_admin", "privacy_officer", "auditor"),
|
||||
related_modules=("core", "access", "audit"),
|
||||
translations={
|
||||
"de": {
|
||||
"title": "Betroffenenanfragen für Richtlinien",
|
||||
"summary": (
|
||||
"Zuordnung von Richtlinienänderungen exportieren, ohne Richtliniendokumente oder eingegrenzte "
|
||||
"Betroffenenkennungen offenzulegen."
|
||||
),
|
||||
"body": (
|
||||
"Policy gleicht innerhalb des aktiven Mandanten nur eine exakte Kontokennung ab und kann eine bereits verifizierte Suche "
|
||||
"auf eine einzelne Überschreibung begrenzen. Ausgegeben werden minimierte Erstellungs- und Änderungsaktivitäten mit "
|
||||
"Richtlinienfamilie, Bereichstyp, Revision und Zeitpunkten. Richtlinienwerte, Ziel- und Bereichsschlüssel, "
|
||||
"Bereichskennungen und Entscheidungsherkunft sind nicht enthalten. Systemweite Überschreibungen werden nicht in eine "
|
||||
"Mandantenanfrage projiziert. Die Zuordnung von Richtlinienänderungen bleibt Governance-Nachweis und wird aufbewahrt, "
|
||||
"statt automatisch gelöscht zu werden."
|
||||
),
|
||||
}
|
||||
},
|
||||
metadata={
|
||||
"help_contexts": ["privacy.data-subject-requests"],
|
||||
"consequence_classes": {
|
||||
@@ -280,6 +320,22 @@ manifest = ModuleManifest(
|
||||
documentation_types=("admin", "user"),
|
||||
audience=("user", "tenant_admin", "policy_admin"),
|
||||
related_modules=("access", "audit", "campaign", "files"),
|
||||
translations={
|
||||
"de": {
|
||||
"title": "Zielpersonen für Zugriffsdiagnosen auswählen",
|
||||
"summary": (
|
||||
"Policy beschränkt Zugriffserklärungen auf die angemeldete Person, sofern die handelnde Person nicht die Berechtigung "
|
||||
"zur Diagnose für ausgewählte Benutzende besitzt."
|
||||
),
|
||||
"body": (
|
||||
"Files und Campaign verwenden die gemeinsame Auswahl für Zugriffserklärungen. Ohne "
|
||||
"policy:access_explanation:select_user liefert Access nur die angemeldete Person und legt keine Metadaten des "
|
||||
"Mandantenverzeichnisses offen. Erlaubte Erklärungen für andere Personen bleiben auf den aktiven Mandanten begrenzt und "
|
||||
"werden als administrative Diagnose im Auditnachweis festgehalten. Die Berechtigung erweitert nur die Sichtbarkeit der "
|
||||
"Diagnose; sie gewährt keinen Zugriff auf die erklärte Ressource."
|
||||
),
|
||||
}
|
||||
},
|
||||
metadata={
|
||||
"kind": "reference",
|
||||
"help_contexts": ["access.resource-explanation.subject"],
|
||||
@@ -290,12 +346,35 @@ manifest = ModuleManifest(
|
||||
title="Govern View availability and actions",
|
||||
summary="View policy limits which definitions and surfaces remain available and which View actions lower scopes may perform.",
|
||||
body=(
|
||||
"Documentation books sit immediately beside the visible heading or contextual label for View "
|
||||
"policy and retention settings, not among operational action buttons. Field help remains "
|
||||
"beside its label. "
|
||||
"System, tenant, group, and user View policies form a restrictive hierarchy. Each scope may inherit, allow, or block viewing, selecting, assigning, editing, deriving, and workflow activation. Optional View-ID and surface-ID ceilings are intersected through the hierarchy, so a lower scope cannot restore an item excluded above it. Available, default, and required View assignments remain owned by Views; Policy supplies the action and catalogue ceiling and records provenance and malformed-policy diagnostics."
|
||||
),
|
||||
layer="configured",
|
||||
documentation_types=("admin", "user"),
|
||||
audience=("system_admin", "tenant_admin", "policy_admin"),
|
||||
related_modules=("views", "admin", "access"),
|
||||
translations={
|
||||
"de": {
|
||||
"title": "View-Verfügbarkeit und -Aktionen steuern",
|
||||
"summary": (
|
||||
"View-Richtlinien begrenzen verfügbare Definitionen und Oberflächen sowie die View-Aktionen, die untergeordnete "
|
||||
"Ebenen ausführen dürfen."
|
||||
),
|
||||
"body": (
|
||||
"Dokumentationsbücher stehen unmittelbar neben der sichtbaren Überschrift oder "
|
||||
"Kontextbezeichnung für Ansichtsrichtlinien und Aufbewahrungseinstellungen, nicht zwischen "
|
||||
"ausführbaren Aktionsschaltflächen. Feldhilfe bleibt neben der Feldbezeichnung. "
|
||||
"View-Richtlinien auf System-, Mandanten-, Gruppen- und Benutzerebene bilden eine einschränkende Hierarchie. Jede Ebene "
|
||||
"kann Anzeigen, Auswählen, Zuweisen, Bearbeiten, Ableiten und Workflow-Aktivierung erben, erlauben oder blockieren. "
|
||||
"Optionale Obergrenzen für View- und Oberflächenkennungen werden entlang der Hierarchie geschnitten, sodass eine "
|
||||
"untergeordnete Ebene einen darüber ausgeschlossenen Eintrag nicht wiederherstellen kann. Verfügbare, standardmäßige "
|
||||
"und verpflichtende View-Zuweisungen gehören weiterhin Views; Policy liefert die Aktions- und Katalogobergrenze und "
|
||||
"zeichnet Herkunft sowie Diagnosen fehlerhafter Richtlinien auf."
|
||||
),
|
||||
}
|
||||
},
|
||||
metadata={
|
||||
"kind": "reference",
|
||||
"help_contexts": [
|
||||
@@ -307,6 +386,66 @@ manifest = ModuleManifest(
|
||||
],
|
||||
},
|
||||
),
|
||||
DocumentationTopic(
|
||||
id="policy.function-assignment-delegation-escalation",
|
||||
title="Govern function delegation and review escalation",
|
||||
summary="Policy bounds complete delegation chains and defines explicit target functions for overdue assignment reviews.",
|
||||
body=(
|
||||
"Tenant defaults and function settings may allow delegation, cap its chain depth and validity, and configure a holder, authority, or recipient review timeout with an exact escalation target function. IDM rechecks the complete current chain and the effective Policy at submission, every decision, recovery, and application. A tightened limit invalidates an old route with an explanation. A timeout creates a visible escalated state but never substitutes an approver or completes the review; a current target-function holder must decide explicitly. Malformed or incomplete escalation rules fail closed."
|
||||
),
|
||||
documentation_types=("admin", "user"),
|
||||
audience=("tenant_admin", "policy_admin", "access_admin", "user"),
|
||||
related_modules=(
|
||||
"idm",
|
||||
"organizations",
|
||||
"workflow_engine",
|
||||
"notifications",
|
||||
"audit",
|
||||
),
|
||||
translations={
|
||||
"de": {
|
||||
"title": "Funktionsdelegation und Prüfeskalation steuern",
|
||||
"summary": (
|
||||
"Policy begrenzt vollständige Delegationsketten und definiert ausdrückliche Zielfunktionen für überfällige "
|
||||
"Zuweisungsprüfungen."
|
||||
),
|
||||
"body": (
|
||||
"Mandantenstandards und Funktionseinstellungen können Delegation erlauben, Kettentiefe und Gültigkeit begrenzen und "
|
||||
"eine Prüfungsfrist für Inhaber, verantwortliche Stelle oder empfangende Person mit exakter Eskalations-Zielfunktion "
|
||||
"festlegen. IDM prüft die vollständige aktuelle Kette und die wirksame Policy bei Einreichung, jeder Entscheidung, "
|
||||
"Wiederherstellung und Anwendung erneut. Eine verschärfte Grenze verwirft einen älteren Weg mit Begründung. Eine "
|
||||
"Fristüberschreitung erzeugt einen sichtbaren eskalierten Zustand, ersetzt aber keine freigebende Person und schließt "
|
||||
"die Prüfung nicht ab; eine aktuelle Inhaberin oder ein aktueller Inhaber der Zielfunktion muss ausdrücklich entscheiden. "
|
||||
"Fehlerhafte oder unvollständige Eskalationsregeln schließen sicher."
|
||||
),
|
||||
}
|
||||
},
|
||||
metadata={
|
||||
"kind": "reference",
|
||||
"help_contexts": [
|
||||
"idm.field.delegation-ceilings",
|
||||
"idm.field.escalation",
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"key": "delegation_allowed",
|
||||
"consequence": "Allows governed derived assignments only when Organizations also marks the function delegable.",
|
||||
},
|
||||
{
|
||||
"key": "maximum_delegation_depth",
|
||||
"consequence": "Rejects longer current chains, including chains accepted before a tighter limit.",
|
||||
},
|
||||
{
|
||||
"key": "maximum_delegated_validity_days",
|
||||
"consequence": "Caps each delegated validity window in addition to its source window.",
|
||||
},
|
||||
{
|
||||
"key": "escalation.<step>",
|
||||
"consequence": "Pins a target function and deadline without granting or substituting approval.",
|
||||
},
|
||||
],
|
||||
},
|
||||
),
|
||||
DocumentationTopic(
|
||||
id="policy.effective-decisions-and-provenance",
|
||||
title="Understand effective policy decisions",
|
||||
@@ -314,6 +453,21 @@ manifest = ModuleManifest(
|
||||
body="A lower scope may narrow an inherited ceiling but cannot silently loosen a stronger system or tenant rule. Consuming modules remain responsible for enforcing the returned decision and displaying its reason. Malformed explicit policy fails closed for the affected governed action rather than being treated as absent.",
|
||||
documentation_types=("user",),
|
||||
audience=("user", "tenant_admin", "policy_admin"),
|
||||
translations={
|
||||
"de": {
|
||||
"title": "Wirksame Richtlinienentscheidungen verstehen",
|
||||
"summary": (
|
||||
"Richtlinienentscheidungen erläutern, ob eine Aktion erlaubt, begrenzt, geerbt oder nicht verfügbar ist, und nennen "
|
||||
"die Quellen des Ergebnisses."
|
||||
),
|
||||
"body": (
|
||||
"Eine untergeordnete Ebene darf eine geerbte Obergrenze verschärfen, aber eine stärkere System- oder Mandantenregel "
|
||||
"nicht stillschweigend lockern. Die nutzenden Module bleiben dafür verantwortlich, die gelieferte Entscheidung "
|
||||
"durchzusetzen und ihre Begründung anzuzeigen. Eine ausdrücklich konfigurierte fehlerhafte Richtlinie schließt die "
|
||||
"betroffene gesteuerte Aktion sicher, statt als nicht vorhanden zu gelten."
|
||||
),
|
||||
}
|
||||
},
|
||||
metadata={"kind": "reference"},
|
||||
),
|
||||
DocumentationTopic(
|
||||
@@ -341,6 +495,26 @@ manifest = ModuleManifest(
|
||||
documentation_types=("admin",),
|
||||
audience=("system_admin", "tenant_admin", "policy_admin"),
|
||||
related_modules=("admin", "audit", "views"),
|
||||
translations={
|
||||
"de": {
|
||||
"title": "Richtlinienauswirkung vor dem Speichern prüfen",
|
||||
"summary": (
|
||||
"Aktuelle und vorgeschlagene wirksame Richtlinie über ausdrücklich ausgewählte, begrenzte Provider-Populationen "
|
||||
"vergleichen, ohne den Vorschlag zu speichern."
|
||||
),
|
||||
"body": (
|
||||
"Die Policy-Auswirkungsvorschau gruppiert neu erlaubte, neu verweigerte, unveränderte und unbestimmte Wirkungen und "
|
||||
"hält Regel-, Quellen- und Bereichsherkunft fest. Aufrufende müssen eine bis zehn Provider-Populationen und je Population "
|
||||
"eine Grenze von höchstens 500 Subjekten wählen; Policy durchsucht die Plattform niemals implizit. Der "
|
||||
"Populationsnachweis kennzeichnet Ergebnisse als vollständig, stichprobenartig, abgeschnitten oder nicht verfügbar. "
|
||||
"Mit Leseberechtigung für Richtlinien sind aggregierte Anzahlen sichtbar, während policy:impact:details "
|
||||
"Ressourcenkennungen und -bezeichnungen steuert. Jede Vorschau wird mit Vorschlagshash und begrenzten Anzahlen auditiert. "
|
||||
"Systemweite View-Richtlinienänderungen verlangen eine Authentifizierung innerhalb der letzten 15 Minuten und behalten "
|
||||
"ihre vorhandenen Audit- und Konfigurationsfreigabenachweise. Optionale Module liefern Subjekte über den Core-Providervertrag; "
|
||||
"Policy importiert weder ihre Modelle noch ihre Dienste."
|
||||
),
|
||||
}
|
||||
},
|
||||
metadata={
|
||||
"kind": "workflow",
|
||||
"route": "/admin?section=system-view-policy",
|
||||
@@ -373,6 +547,7 @@ manifest = ModuleManifest(
|
||||
summary="Restrict password-protected Campaign ZIP formats and password-delivery channels through an explainable hierarchy.",
|
||||
body=(
|
||||
"The secure baseline permits AES only. An authorized policy administrator may explicitly permit legacy ZipCrypto at system scope, after which tenant, owner group or user, and campaign rules may only narrow the inherited methods. The same intersection controls the separate channel used to convey a password. Policy records the complete source path and a stable policy hash; malformed configuration fails closed. Policy changes never rewrite old build evidence, while Campaign rejects a queued or sent build whose effective policy is now more restrictive."
|
||||
" To configure the exception, open Administration → SYSTEM → Campaign archive encryption, enable Legacy ZipCrypto, and Save. The system methods and channels remain editable before any explicit override exists; opening default settings alone does not create an override or unsaved changes. Lower scopes inherit until their inheritance switch is disabled and may select only parent-permitted methods and channels. Campaign Settings, Policies, and Attachments link authorized readers to the system and tenant settings and let them reload effective policy. Reading requires admin:policies:read. Saving the global system ceiling requires both system:settings:write and admin:policies:write; lower-scope saves require admin:policies:write. Core's configuration safety catalog validates this registered setting and retains audited before/after and rollback choices; only the two validated format/channel enum lists are exempted from password-name redaction, never real secrets or unknown values. Using the exception additionally requires Campaign's dedicated legacy-encryption permission and a weak-encryption acknowledgment with a reason of at least 10 characters. Saving policy does not send mail or silently change any archive's selected method."
|
||||
),
|
||||
documentation_types=("admin", "user"),
|
||||
audience=(
|
||||
@@ -382,6 +557,43 @@ manifest = ModuleManifest(
|
||||
"campaign_manager",
|
||||
),
|
||||
related_modules=("campaign", "audit", "access"),
|
||||
links=(
|
||||
DocumentationLink(
|
||||
label="System Campaign archive encryption",
|
||||
href="/admin?section=system-campaign-archive-encryption",
|
||||
kind="runtime",
|
||||
),
|
||||
DocumentationLink(
|
||||
label="Tenant Campaign archive encryption",
|
||||
href="/admin?section=tenant-campaign-archive-encryption",
|
||||
kind="runtime",
|
||||
),
|
||||
),
|
||||
translations={
|
||||
"de": {
|
||||
"title": "Verschlüsselung von Campaign-Archiven steuern",
|
||||
"summary": (
|
||||
"Formate passwortgeschützter Campaign-ZIP-Dateien und Übertragungskanäle für Passwörter über eine erklärbare "
|
||||
"Hierarchie einschränken."
|
||||
),
|
||||
"body": (
|
||||
"Die sichere Grundlage erlaubt nur AES. Eine berechtigte Richtlinienadministration kann das veraltete ZipCrypto auf "
|
||||
"Systemebene ausdrücklich zulassen; Regeln auf Mandanten-, Eigentümergruppen-, Benutzer- und Campaign-Ebene dürfen die "
|
||||
"geerbten Methoden anschließend nur weiter einschränken. Derselbe Schnitt steuert getrennt den Kanal zur Übermittlung "
|
||||
"eines Passworts. Policy zeichnet den vollständigen Quellenpfad und einen stabilen Richtlinienhash auf; fehlerhafte "
|
||||
"Konfiguration schließt sicher. Richtlinienänderungen schreiben alte Erstellungsnachweise niemals um, während Campaign "
|
||||
"einen eingereihten oder versandten Build zurückweist, wenn dessen wirksame Richtlinie inzwischen strenger ist."
|
||||
" Öffnen Sie zur Konfiguration Administration → SYSTEM → Campaign archive encryption, aktivieren Sie Legacy ZipCrypto und speichern Sie. "
|
||||
"Methoden und Kanäle auf Systemebene sind schon vor der ersten ausdrücklichen Ausnahme bearbeitbar; das bloße Öffnen erzeugt weder eine Ausnahme noch ungespeicherte Änderungen. "
|
||||
"Untergeordnete Ebenen erben bis zum Abschalten ihres Vererbungsschalters und dürfen nur übergeordnet erlaubte Methoden und Kanäle wählen. "
|
||||
"Kampagneneinstellungen, Richtlinien und Anhänge verlinken berechtigte Lesende auf System- und Mandantenkonfiguration und erlauben das Neuladen der wirksamen Richtlinie. "
|
||||
"Lesen erfordert admin:policies:read. Das Speichern der globalen Systemgrenze benötigt system:settings:write und admin:policies:write gemeinsam; untergeordnete Ebenen benötigen admin:policies:write. "
|
||||
"Der zentrale Konfigurations-Sicherheitskatalog prüft dieses registrierte Feld und bewahrt auditierte Vorher-/Nachherwerte sowie Rücknahmewerte. Nur die beiden validierten Format-/Kanal-Enumlisten bleiben trotz Passwortbegriff im Feldnamen sichtbar, niemals echte Geheimnisse oder unbekannte Werte. "
|
||||
"Die Nutzung benötigt zusätzlich Campaigns gesonderte Legacy-Verschlüsselungsberechtigung und die Bestätigung schwacher Verschlüsselung mit mindestens 10 Zeichen Begründung. "
|
||||
"Das Speichern einer Richtlinie versendet keine E-Mail und ändert keine gewählte Archivmethode stillschweigend."
|
||||
),
|
||||
}
|
||||
},
|
||||
metadata={
|
||||
"kind": "reference",
|
||||
"help_contexts": [
|
||||
@@ -395,6 +607,9 @@ manifest = ModuleManifest(
|
||||
title="Administer policy hierarchy and overrides",
|
||||
summary="Policy evaluates versioned system, tenant, group, and user rules for retention and module-owned governed actions.",
|
||||
body=(
|
||||
"Documentation books sit immediately beside the visible heading or contextual label for View "
|
||||
"policy and retention settings, not among operational action buttons. Field help remains "
|
||||
"beside its label. "
|
||||
"Retention fields govern separate data classes: raw campaign JSON, generated EML artifacts, stored report details, mock-mailbox records, and audit details. A blank system day limit keeps the class indefinitely; a blank lower-scope value inherits its parent. Lower scopes may only shorten an allowed limit or reduce audit detail. Disabling raw campaign JSON makes it immediately eligible for redaction when retention is applied. Audit detail level controls how new audit details are recorded, while audit-detail retention redacts eligible historical detail but preserves the audit record and a bounded retention marker. The lower-level switch controls whether child scopes may narrow that specific field. Inspect the effective value and source path before saving."
|
||||
),
|
||||
documentation_types=("admin",),
|
||||
@@ -415,7 +630,10 @@ manifest = ModuleManifest(
|
||||
"de": {
|
||||
"title": "Richtlinienhierarchie und Aufbewahrung verwalten",
|
||||
"summary": "Policy wertet versionierte System-, Mandanten-, Gruppen- und Benutzerregeln für Aufbewahrung sowie modulbezogene Steuerungsentscheidungen aus.",
|
||||
"body": "Die Felder steuern getrennte Datenklassen: Kampagnen-Rohdaten im JSON-Format, erzeugte EML-Dateien, gespeicherte Berichtsdetails, Einträge im Testpostfach und Auditdetails. Ein leeres Tageslimit auf Systemebene bedeutet unbegrenzte Aufbewahrung; auf tieferen Ebenen wird der Elternwert geerbt. Tiefere Ebenen dürfen ein erlaubtes Limit nur verkürzen oder Auditdetails weiter reduzieren. Wenn die Speicherung von Kampagnen-Rohdaten deaktiviert wird, werden diese bei der nächsten Ausführung sofort zur Schwärzung vorgemerkt. Die Auditdetailstufe steuert neue Auditdetails; die Aufbewahrungsfrist für Auditdetails schwärzt historische Details, erhält aber den Auditdatensatz und einen begrenzten Aufbewahrungsnachweis. Der Schalter für tiefere Ebenen bestimmt, ob Kindebenen genau dieses Feld weiter einschränken dürfen. Prüfen Sie vor dem Speichern den effektiven Wert und seinen Quellenpfad.",
|
||||
"body": "Dokumentationsbücher stehen unmittelbar neben der sichtbaren Überschrift oder "
|
||||
"Kontextbezeichnung für Ansichtsrichtlinien und Aufbewahrungseinstellungen, nicht zwischen "
|
||||
"ausführbaren Aktionsschaltflächen. Feldhilfe bleibt neben der Feldbezeichnung. "
|
||||
"Die Felder steuern getrennte Datenklassen: Kampagnen-Rohdaten im JSON-Format, erzeugte EML-Dateien, gespeicherte Berichtsdetails, Einträge im Testpostfach und Auditdetails. Ein leeres Tageslimit auf Systemebene bedeutet unbegrenzte Aufbewahrung; auf tieferen Ebenen wird der Elternwert geerbt. Tiefere Ebenen dürfen ein erlaubtes Limit nur verkürzen oder Auditdetails weiter reduzieren. Wenn die Speicherung von Kampagnen-Rohdaten deaktiviert wird, werden diese bei der nächsten Ausführung sofort zur Schwärzung vorgemerkt. Die Auditdetailstufe steuert neue Auditdetails; die Aufbewahrungsfrist für Auditdetails schwärzt historische Details, erhält aber den Auditdatensatz und einen begrenzten Aufbewahrungsnachweis. Der Schalter für tiefere Ebenen bestimmt, ob Kindebenen genau dieses Feld weiter einschränken dürfen. Prüfen Sie vor dem Speichern den effektiven Wert und seinen Quellenpfad.",
|
||||
}
|
||||
},
|
||||
metadata={
|
||||
@@ -696,5 +914,10 @@ manifest = ModuleManifest(
|
||||
)
|
||||
|
||||
|
||||
manifest = with_documentation_structured_translations(
|
||||
manifest, locale="de", translations=GERMAN_STRUCTURED_TRANSLATIONS
|
||||
)
|
||||
|
||||
|
||||
def get_manifest() -> ModuleManifest:
|
||||
return manifest
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from types import SimpleNamespace
|
||||
import unittest
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy.pool import StaticPool
|
||||
|
||||
from govoplan_core.admin.models import SystemSettings
|
||||
from govoplan_core.auth import ApiPrincipal, get_api_principal
|
||||
from govoplan_core.core.access import PrincipalRef
|
||||
from govoplan_core.core.change_sequence import ChangeSequenceEntry
|
||||
from govoplan_core.core.configuration_control import (
|
||||
configuration_control_snapshot,
|
||||
create_configuration_change_request,
|
||||
)
|
||||
from govoplan_core.core.configuration_safety import (
|
||||
classify_configuration_field,
|
||||
plan_configuration_change,
|
||||
)
|
||||
from govoplan_core.db.session import get_session
|
||||
from govoplan_policy.backend.api.v1.routes import router
|
||||
from govoplan_policy.backend.db.models import PolicyOverride
|
||||
|
||||
|
||||
class CampaignArchiveEncryptionApiTests(unittest.TestCase):
|
||||
"""Exercise the real HTTP route, safety catalog, persistence, and history."""
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.engine = create_engine(
|
||||
"sqlite:///:memory:",
|
||||
connect_args={"check_same_thread": False},
|
||||
poolclass=StaticPool,
|
||||
)
|
||||
self.addCleanup(self.engine.dispose)
|
||||
for table in (SystemSettings.__table__, PolicyOverride.__table__, ChangeSequenceEntry.__table__):
|
||||
table.create(self.engine)
|
||||
self.principal = self._principal("admin:policies:read", "admin:policies:write", "system:settings:write")
|
||||
app = FastAPI()
|
||||
app.include_router(router, prefix="/api/v1")
|
||||
|
||||
def session_dependency():
|
||||
with Session(self.engine) as session:
|
||||
yield session
|
||||
|
||||
app.dependency_overrides[get_session] = session_dependency
|
||||
app.dependency_overrides[get_api_principal] = lambda: self.principal
|
||||
self.client = TestClient(app)
|
||||
self.addCleanup(self.client.close)
|
||||
|
||||
@staticmethod
|
||||
def _principal(*scopes: str) -> ApiPrincipal:
|
||||
return ApiPrincipal(
|
||||
principal=PrincipalRef(
|
||||
account_id="admin-account", membership_id="admin-user", tenant_id="tenant-1",
|
||||
scopes=frozenset(scopes),
|
||||
),
|
||||
account=SimpleNamespace(id="admin-account"),
|
||||
user=SimpleNamespace(id="admin-user"),
|
||||
)
|
||||
|
||||
def test_system_legacy_opt_in_passes_real_catalog_and_retains_history(self) -> None:
|
||||
path = "/api/v1/admin/campaign-archive-encryption/policies/system"
|
||||
field = classify_configuration_field("campaign_archive_encryption_policy")
|
||||
self.assertIsNotNone(field)
|
||||
self.assertEqual("policy", field.owner_module)
|
||||
self.assertTrue(field.validation_required)
|
||||
self.assertTrue(field.rollback_history_required)
|
||||
self.assertEqual({}, self.client.get(path).json()["policy"])
|
||||
policy = {
|
||||
"allowed_password_encryption_methods": ["aes", "zip_standard"],
|
||||
"allowed_password_delivery_channels": ["phone", "letter"],
|
||||
}
|
||||
response = self.client.put(path, json={"policy": policy})
|
||||
self.assertEqual(200, response.status_code, response.text)
|
||||
self.assertEqual(policy["allowed_password_encryption_methods"], response.json()["effective_policy"]["allowed_password_encryption_methods"])
|
||||
loaded = self.client.get(path)
|
||||
self.assertEqual(200, loaded.status_code)
|
||||
self.assertEqual(policy, loaded.json()["policy"])
|
||||
with Session(self.engine) as session:
|
||||
history = configuration_control_snapshot(session)["history"]
|
||||
self.assertEqual(1, len(history))
|
||||
self.assertEqual("campaign_archive_encryption_policy", history[0]["key"])
|
||||
self.assertEqual("campaign_archive_encryption_policy.updated", history[0]["audit_event"])
|
||||
self.assertEqual({}, history[0]["before"])
|
||||
self.assertEqual(policy, history[0]["after"])
|
||||
self.assertTrue(history[0]["plan"]["allowed"])
|
||||
self.assertEqual([], history[0]["plan"]["blockers"])
|
||||
audit_changes = session.query(ChangeSequenceEntry).filter(
|
||||
ChangeSequenceEntry.module_id == "audit"
|
||||
).all()
|
||||
self.assertEqual(1, len(audit_changes))
|
||||
self.assertEqual("campaign_archive_encryption_policy.updated", audit_changes[0].payload["action"])
|
||||
|
||||
narrowed_policy = {"allowed_password_encryption_methods": ["aes"]}
|
||||
narrowed = self.client.put(path, json={"policy": narrowed_policy})
|
||||
self.assertEqual(200, narrowed.status_code, narrowed.text)
|
||||
with Session(self.engine) as session:
|
||||
history = configuration_control_snapshot(session)["history"]
|
||||
self.assertEqual(2, len(history))
|
||||
self.assertEqual(policy, history[0]["before"])
|
||||
self.assertEqual(policy, history[0]["rollback_value"])
|
||||
self.assertEqual(narrowed_policy, history[0]["after"])
|
||||
|
||||
def test_read_only_actor_cannot_change_system_policy(self) -> None:
|
||||
self.principal = self._principal("admin:policies:read")
|
||||
policy = {"allowed_password_encryption_methods": ["aes", "zip_standard"]}
|
||||
response = self.client.put(
|
||||
"/api/v1/admin/campaign-archive-encryption/policies/system", json={"policy": policy}
|
||||
)
|
||||
self.assertEqual(403, response.status_code)
|
||||
plan = plan_configuration_change("campaign_archive_encryption_policy", actor_scopes=tuple(self.principal.scopes), value=policy)
|
||||
self.assertFalse(plan.allowed)
|
||||
self.assertEqual(("system:settings:write", "admin:policies:write"), plan.missing_scopes)
|
||||
with Session(self.engine) as session:
|
||||
self.assertEqual(0, session.query(PolicyOverride).count())
|
||||
|
||||
def test_tenant_policy_writer_cannot_loosen_global_system_ceiling(self) -> None:
|
||||
self.principal = self._principal("admin:policies:read", "admin:policies:write")
|
||||
policy = {"allowed_password_encryption_methods": ["aes", "zip_standard"]}
|
||||
response = self.client.put(
|
||||
"/api/v1/admin/campaign-archive-encryption/policies/system", json={"policy": policy}
|
||||
)
|
||||
self.assertIn(response.status_code, (403, 409))
|
||||
self.assertIn("system:settings:write", response.text)
|
||||
with Session(self.engine) as session:
|
||||
self.assertEqual(0, session.query(PolicyOverride).count())
|
||||
self.assertEqual(0, session.query(ChangeSequenceEntry).count())
|
||||
|
||||
narrowed = self.client.put(
|
||||
"/api/v1/admin/campaign-archive-encryption/policies/tenant",
|
||||
json={"policy": {"allowed_password_encryption_methods": ["aes"]}},
|
||||
)
|
||||
self.assertEqual(200, narrowed.status_code, narrowed.text)
|
||||
|
||||
def test_invalid_method_and_child_ceiling_still_fail_closed(self) -> None:
|
||||
path = "/api/v1/admin/campaign-archive-encryption/policies"
|
||||
invalid = self.client.put(f"{path}/system", json={"policy": {"allowed_password_encryption_methods": ["plaintext"]}})
|
||||
self.assertEqual(422, invalid.status_code)
|
||||
child = self.client.put(f"{path}/tenant", json={"policy": {"allowed_password_encryption_methods": ["aes", "zip_standard"]}})
|
||||
self.assertEqual(422, child.status_code)
|
||||
self.assertIn("parent", child.text)
|
||||
with Session(self.engine) as session:
|
||||
self.assertEqual(0, session.query(PolicyOverride).count())
|
||||
|
||||
def test_configuration_preview_preserves_only_known_non_secret_enum_lists(self) -> None:
|
||||
unsafe = {
|
||||
"allowed_password_encryption_methods": ["aes", "literal-secret"],
|
||||
"allowed_password_delivery_channels": {"password": "nested-secret"},
|
||||
"password": "actual-secret",
|
||||
"arbitrary_field": ["unknown-secret"],
|
||||
}
|
||||
with Session(self.engine) as session:
|
||||
request = create_configuration_change_request(
|
||||
session,
|
||||
key="campaign_archive_encryption_policy",
|
||||
value=unsafe,
|
||||
actor_user_id="admin-user",
|
||||
actor_scopes=tuple(self.principal.scopes),
|
||||
dry_run=False,
|
||||
target={"scope_type": "system"},
|
||||
)
|
||||
self.assertEqual({key: "<redacted>" for key in unsafe}, request["value_preview"])
|
||||
self.assertNotIn("literal-secret", str(configuration_control_snapshot(session)))
|
||||
self.assertNotIn("actual-secret", str(configuration_control_snapshot(session)))
|
||||
for malformed in ("scalar-secret", ["list-secret"], None, 7):
|
||||
with self.subTest(malformed=type(malformed).__name__):
|
||||
malformed_request = create_configuration_change_request(
|
||||
session,
|
||||
key="campaign_archive_encryption_policy",
|
||||
value=malformed,
|
||||
actor_user_id="admin-user",
|
||||
actor_scopes=tuple(self.principal.scopes),
|
||||
dry_run=False,
|
||||
target={"scope_type": "system"},
|
||||
)
|
||||
self.assertEqual("<redacted>", malformed_request["value_preview"])
|
||||
snapshot = str(configuration_control_snapshot(session))
|
||||
self.assertNotIn("scalar-secret", snapshot)
|
||||
self.assertNotIn("list-secret", snapshot)
|
||||
invalid = self.client.put(
|
||||
"/api/v1/admin/campaign-archive-encryption/policies/system",
|
||||
json={"policy": unsafe},
|
||||
)
|
||||
self.assertEqual(422, invalid.status_code)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -132,6 +132,58 @@ class FunctionAssignmentGovernancePolicyTests(unittest.TestCase):
|
||||
self.assertTrue(responder.allowed)
|
||||
self.assertFalse(unrelated.allowed)
|
||||
|
||||
def test_delegation_ceilings_and_escalation_rules_are_bounded(self) -> None:
|
||||
decision = self.resolve(
|
||||
function_settings={
|
||||
"assignment_governance": {
|
||||
"request_profile": "holder_with_authority_clearance",
|
||||
"authority_function_id": "authority-1",
|
||||
"delegation_allowed": True,
|
||||
"maximum_delegation_depth": 3,
|
||||
"maximum_delegated_validity_days": 45,
|
||||
"escalation": {
|
||||
"holder": {
|
||||
"target_function_id": "escalation-1",
|
||||
"timeout_hours": 24,
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
self.assertTrue(decision.delegation_allowed)
|
||||
self.assertEqual(3, decision.maximum_delegation_depth)
|
||||
self.assertEqual(45, decision.maximum_delegated_validity_days)
|
||||
self.assertEqual("escalation-1", decision.escalation_rules[0].target_function_id)
|
||||
self.assertEqual(24, decision.escalation_rules[0].timeout_hours)
|
||||
|
||||
def test_escalated_review_requires_explicit_target_holder(self) -> None:
|
||||
allowed = self.resolve(
|
||||
action="approve_escalation",
|
||||
current_state="escalated",
|
||||
context={
|
||||
"actor_is_escalation_target": True,
|
||||
"actor_routes": {"escalation": {"effective": True}},
|
||||
},
|
||||
)
|
||||
unavailable = self.resolve(
|
||||
action="approve_escalation",
|
||||
current_state="escalated",
|
||||
context={
|
||||
"actor_is_escalation_target": False,
|
||||
"actor_routes": {
|
||||
"escalation": {
|
||||
"effective": False,
|
||||
"reason": "The target function is vacant.",
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
self.assertTrue(allowed.allowed)
|
||||
self.assertFalse(unavailable.allowed)
|
||||
self.assertEqual("The target function is vacant.", unavailable.reason)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
@@ -26,6 +26,18 @@ ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
class PolicyModuleContractTests(unittest.TestCase):
|
||||
def test_all_static_topics_have_complete_german_content(self) -> None:
|
||||
for topic in manifest.documentation:
|
||||
german = (topic.translations or {}).get("de", {})
|
||||
self.assertEqual(
|
||||
{"title", "summary", "body"},
|
||||
set(german),
|
||||
topic.id,
|
||||
)
|
||||
self.assertTrue(
|
||||
all(str(value).strip() for value in german.values()), topic.id
|
||||
)
|
||||
|
||||
def test_policy_package_does_not_hard_require_access(self) -> None:
|
||||
project = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding="utf-8"))[
|
||||
"project"
|
||||
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@govoplan/policy-webui",
|
||||
"version": "0.1.19",
|
||||
"version": "0.1.23",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
@@ -13,10 +13,11 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test:interface-patterns": "node scripts/test-interface-pattern-language.mjs"
|
||||
"test:interface-patterns": "node scripts/test-interface-pattern-language.mjs",
|
||||
"test:archive-encryption": "node --experimental-strip-types scripts/test-archive-encryption-draft.mjs"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@govoplan/core-webui": "^0.1.18",
|
||||
"@govoplan/core-webui": "^0.1.45",
|
||||
"lucide-react": "^1.23.0",
|
||||
"react": ">=19.2.7 <20",
|
||||
"react-dom": ">=19.2.7 <20",
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import {
|
||||
buildPolicy, draftFromPolicy, inheritedControlDisabled, setDraftChannel,
|
||||
setDraftMethod, stable
|
||||
} from "../src/features/policy/archiveEncryptionDraft.ts";
|
||||
|
||||
const baseline = {
|
||||
allowed_password_encryption_methods: ["aes"],
|
||||
allowed_password_delivery_channels: ["separate_mail", "sms", "letter", "phone", "in_person"],
|
||||
policy_hash: "baseline", source_path: [], reason: "Secure baseline", diagnostics: []
|
||||
};
|
||||
const initial = draftFromPolicy({}, baseline);
|
||||
assert.deepEqual(buildPolicy(initial), {}, "Opening default system settings must not create an override or dirty state");
|
||||
assert.equal(inheritedControlDisabled("system", initial.inheritMethods), false, "System defaults must be editable without a hidden inheritance toggle");
|
||||
assert.equal(inheritedControlDisabled("system", initial.inheritChannels), false);
|
||||
const enabled = setDraftMethod(initial, "zip_standard", true);
|
||||
assert.deepEqual(buildPolicy(enabled), { allowed_password_encryption_methods: ["aes", "zip_standard"] }, "The first system Legacy click must produce an explicit override");
|
||||
assert.notEqual(stable(buildPolicy(enabled)), stable({}));
|
||||
assert.deepEqual(buildPolicy(initial), {}, "Changing a draft must preserve the original policy");
|
||||
const narrowedChannels = setDraftChannel(initial, "sms", false);
|
||||
assert.deepEqual(buildPolicy(narrowedChannels), { allowed_password_delivery_channels: ["separate_mail", "letter", "phone", "in_person"] });
|
||||
assert.equal(inheritedControlDisabled("tenant", initial.inheritMethods), true, "Child scopes retain explicit inheritance controls");
|
||||
assert.equal(inheritedControlDisabled("user", false), false);
|
||||
assert.deepEqual(buildPolicy(draftFromPolicy(buildPolicy(enabled), baseline)), buildPolicy(enabled), "An explicit system policy survives save/reload");
|
||||
assert.deepEqual(buildPolicy(setDraftMethod(enabled, "zip_standard", false)), { allowed_password_encryption_methods: ["aes"] });
|
||||
|
||||
const panel = readFileSync(new URL("../src/features/policy/ArchiveEncryptionPoliciesPanel.tsx", import.meta.url), "utf8");
|
||||
assert.match(panel, /inheritedControlDisabled\(scopeType, draft\.inheritMethods\)/);
|
||||
assert.match(panel, /inheritedControlDisabled\(scopeType, draft\.inheritChannels\)/);
|
||||
assert.match(panel, /setDraft\(setDraftMethod\(draft, method\.id, checked\)\)/);
|
||||
assert.match(panel, /setDraft\(setDraftChannel\(draft, channel\.id, checked\)\)/);
|
||||
assert.match(panel, /scopeType !== "system" && !parentMethods\.includes\(method\.id\)/, "Child scopes must still respect parent ceilings");
|
||||
const moduleSource = readFileSync(new URL("../src/module.ts", import.meta.url), "utf8");
|
||||
assert.match(moduleSource, /scopeType: "system",\s*canWrite: hasScope\(auth, "system:settings:write"\) && hasScope\(auth, "admin:policies:write"\)/, "Tenant policy administration alone must not enable edits to the global system archive ceiling");
|
||||
console.log("Archive encryption settings regressions passed.");
|
||||
@@ -20,11 +20,19 @@ import {
|
||||
fetchArchiveEncryptionPolicy,
|
||||
updateArchiveEncryptionPolicy,
|
||||
type ArchiveEncryptionMethod,
|
||||
type ArchiveEncryptionPolicyItem,
|
||||
type ArchiveEncryptionPolicyResponse,
|
||||
type ArchiveEncryptionPolicyScope,
|
||||
type PasswordDeliveryChannel
|
||||
} from "../../api/archiveEncryptionPolicies";
|
||||
import {
|
||||
buildPolicy,
|
||||
draftFromPolicy,
|
||||
inheritedControlDisabled,
|
||||
setDraftChannel,
|
||||
setDraftMethod,
|
||||
stable,
|
||||
type ArchiveEncryptionDraft
|
||||
} from "./archiveEncryptionDraft";
|
||||
|
||||
type Props = {
|
||||
settings: ApiSettings;
|
||||
@@ -32,13 +40,6 @@ type Props = {
|
||||
canWrite: boolean;
|
||||
};
|
||||
|
||||
type Draft = {
|
||||
inheritMethods: boolean;
|
||||
methods: ArchiveEncryptionMethod[];
|
||||
inheritChannels: boolean;
|
||||
channels: PasswordDeliveryChannel[];
|
||||
};
|
||||
|
||||
const METHODS: Array<{ id: ArchiveEncryptionMethod; label: string; description: string }> = [
|
||||
{ id: "aes", label: "AES (strong, default)", description: "Modern AES encryption for compatible ZIP clients." },
|
||||
{ id: "zip_standard", label: "Legacy ZipCrypto — Windows-compatible, weak encryption", description: "Requires a separate Campaign permission and reasoned acknowledgement." }
|
||||
@@ -56,7 +57,7 @@ export default function ArchiveEncryptionPoliciesPanel({ settings, scopeType, ca
|
||||
const [targets, setTargets] = useState<SearchableSelectOption[]>([]);
|
||||
const [targetId, setTargetId] = useState("");
|
||||
const [state, setState] = useState<ArchiveEncryptionPolicyResponse | null>(null);
|
||||
const [draft, setDraft] = useState<Draft | null>(null);
|
||||
const [draft, setDraft] = useState<ArchiveEncryptionDraft | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
@@ -157,11 +158,11 @@ export default function ArchiveEncryptionPoliciesPanel({ settings, scopeType, ca
|
||||
</DismissibleAlert>
|
||||
<Card title="Allowed password-encryption methods">
|
||||
{scopeType !== "system" && <ToggleSwitch label="Inherit methods from the parent scope" checked={draft.inheritMethods} disabled={!canWrite || busy} onChange={(checked) => setDraft({ ...draft, inheritMethods: checked, methods: checked ? [...parentMethods] : draft.methods })} />}
|
||||
{METHODS.map((method) => <ToggleSwitch key={method.id} label={method.label} help={method.description} checked={draft.methods.includes(method.id)} disabled={!canWrite || busy || draft.inheritMethods || (scopeType !== "system" && !parentMethods.includes(method.id))} onChange={(checked) => setDraft({ ...draft, methods: toggle(draft.methods, method.id, checked) })} />)}
|
||||
{METHODS.map((method) => <ToggleSwitch key={method.id} label={method.label} help={method.description} checked={draft.methods.includes(method.id)} disabled={!canWrite || busy || inheritedControlDisabled(scopeType, draft.inheritMethods) || (scopeType !== "system" && !parentMethods.includes(method.id))} onChange={(checked) => setDraft(setDraftMethod(draft, method.id, checked))} />)}
|
||||
</Card>
|
||||
<Card title="Allowed separate password-delivery channels">
|
||||
{scopeType !== "system" && <ToggleSwitch label="Inherit channels from the parent scope" checked={draft.inheritChannels} disabled={!canWrite || busy} onChange={(checked) => setDraft({ ...draft, inheritChannels: checked, channels: checked ? [...parentChannels] : draft.channels })} />}
|
||||
{CHANNELS.map((channel) => <ToggleSwitch key={channel.id} label={channel.label} checked={draft.channels.includes(channel.id)} disabled={!canWrite || busy || draft.inheritChannels || (scopeType !== "system" && !parentChannels.includes(channel.id))} onChange={(checked) => setDraft({ ...draft, channels: toggle(draft.channels, channel.id, checked) })} />)}
|
||||
{CHANNELS.map((channel) => <ToggleSwitch key={channel.id} label={channel.label} checked={draft.channels.includes(channel.id)} disabled={!canWrite || busy || inheritedControlDisabled(scopeType, draft.inheritChannels) || (scopeType !== "system" && !parentChannels.includes(channel.id))} onChange={(checked) => setDraft(setDraftChannel(draft, channel.id, checked))} />)}
|
||||
</Card>
|
||||
<Card title="Effective policy evidence">
|
||||
<DescriptionList>
|
||||
@@ -173,33 +174,6 @@ export default function ArchiveEncryptionPoliciesPanel({ settings, scopeType, ca
|
||||
</AdminPageLayout>;
|
||||
}
|
||||
|
||||
function draftFromPolicy(policy: ArchiveEncryptionPolicyItem, parent: ArchiveEncryptionPolicyResponse["parent_policy"]): Draft {
|
||||
return {
|
||||
inheritMethods: policy.allowed_password_encryption_methods === undefined,
|
||||
methods: [...(policy.allowed_password_encryption_methods ?? parent.allowed_password_encryption_methods)],
|
||||
inheritChannels: policy.allowed_password_delivery_channels === undefined,
|
||||
channels: [...(policy.allowed_password_delivery_channels ?? parent.allowed_password_delivery_channels)]
|
||||
};
|
||||
}
|
||||
|
||||
function buildPolicy(draft: Draft): ArchiveEncryptionPolicyItem {
|
||||
return {
|
||||
...(draft.inheritMethods ? {} : { allowed_password_encryption_methods: draft.methods }),
|
||||
...(draft.inheritChannels ? {} : { allowed_password_delivery_channels: draft.channels })
|
||||
};
|
||||
}
|
||||
|
||||
function stable(value: ArchiveEncryptionPolicyItem): string {
|
||||
return JSON.stringify({
|
||||
methods: value.allowed_password_encryption_methods ? [...value.allowed_password_encryption_methods].sort() : null,
|
||||
channels: value.allowed_password_delivery_channels ? [...value.allowed_password_delivery_channels].sort() : null
|
||||
});
|
||||
}
|
||||
|
||||
function toggle<T extends string>(values: T[], value: T, checked: boolean): T[] {
|
||||
return checked ? Array.from(new Set([...values, value])) : values.filter((item) => item !== value);
|
||||
}
|
||||
|
||||
async function loadTargets(settings: ApiSettings, scope: ArchiveEncryptionPolicyScope): Promise<SearchableSelectOption[]> {
|
||||
if (scope === "group") {
|
||||
const response = await fetchGroupsDelta(settings, { limit: 1000 });
|
||||
|
||||
@@ -189,7 +189,7 @@ export default function RetentionPoliciesPanel({ settings, scopeType, canWrite }
|
||||
return (
|
||||
<>
|
||||
<AdminPageLayout
|
||||
title={labels.title}
|
||||
title={labels.title} titleHelp={<DocumentationHelpLink reference={RETENTION_DOCUMENTATION} label="i18n:govoplan-core.open_admin_documentation.6adbdae3" />}
|
||||
description={labels.description}
|
||||
helpContextId="policy.retention"
|
||||
loading={loadingTargets}
|
||||
@@ -209,7 +209,7 @@ export default function RetentionPoliciesPanel({ settings, scopeType, canWrite }
|
||||
<RefreshCw size={16} />
|
||||
</Button>
|
||||
)}
|
||||
<DocumentationHelpLink reference={RETENTION_DOCUMENTATION} label="i18n:govoplan-core.open_admin_documentation.6adbdae3" />
|
||||
|
||||
</>
|
||||
}
|
||||
>
|
||||
@@ -226,9 +226,9 @@ export default function RetentionPoliciesPanel({ settings, scopeType, canWrite }
|
||||
{scopeType === "system" && (
|
||||
<div className="retention-run-section">
|
||||
<Card
|
||||
title="Retention execution"
|
||||
title="Retention execution" titleHelp={<DocumentationHelpLink reference={RETENTION_DOCUMENTATION} label="i18n:govoplan-core.open_admin_documentation.6adbdae3" />}
|
||||
helpContextId="policy.retention.execution"
|
||||
actions={<DocumentationHelpLink reference={RETENTION_DOCUMENTATION} label="i18n:govoplan-core.open_admin_documentation.6adbdae3" />}
|
||||
|
||||
>
|
||||
<p className="muted small-note">Run the saved effective retention policy against retained platform data.</p>
|
||||
<div className="button-row compact-actions subsection-bottom-actions">
|
||||
|
||||
@@ -315,7 +315,7 @@ export default function ViewPoliciesPanel({ settings, scopeType, canWrite }: Pro
|
||||
return (
|
||||
<>
|
||||
<AdminPageLayout
|
||||
title={`${scopeLabel} View policy`}
|
||||
title={`${scopeLabel} View policy`} titleHelp={<DocumentationHelpLink reference={DOCUMENTATION} label="Open View policy documentation" />}
|
||||
description="Control which Views and surfaces are available, forced by assignment, selectable, editable, derivable, or workflow-activatable at this scope."
|
||||
loading={loading}
|
||||
error={error}
|
||||
@@ -329,7 +329,7 @@ export default function ViewPoliciesPanel({ settings, scopeType, canWrite }: Pro
|
||||
<Button onClick={() => void prepareResetPolicy()} disabled={!canWrite || !state?.id || busy}><Trash2 size={16} /> Use inherited</Button>
|
||||
<Button helpContextId="policy.impact-preview.action.preview" onClick={() => void previewImpact()} disabled={!canWrite || !dirty || busy}><ScanSearch size={16} /> Preview impact</Button>
|
||||
<Button variant="primary" onClick={() => void save()} disabled={!canWrite || !dirty || busy || !previewCurrent} disabledReason={dirty && !previewCurrent ? "Preview the current draft before saving." : undefined}><Save size={16} /> {busy ? "Working..." : "Save"}</Button>
|
||||
<DocumentationHelpLink reference={DOCUMENTATION} label="Open View policy documentation" />
|
||||
|
||||
</>
|
||||
}
|
||||
>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import type {
|
||||
ArchiveEncryptionMethod,
|
||||
ArchiveEncryptionPolicyItem,
|
||||
ArchiveEncryptionPolicyResponse,
|
||||
ArchiveEncryptionPolicyScope,
|
||||
PasswordDeliveryChannel
|
||||
} from "../../api/archiveEncryptionPolicies";
|
||||
|
||||
export type ArchiveEncryptionDraft = {
|
||||
inheritMethods: boolean;
|
||||
methods: ArchiveEncryptionMethod[];
|
||||
inheritChannels: boolean;
|
||||
channels: PasswordDeliveryChannel[];
|
||||
};
|
||||
|
||||
export function draftFromPolicy(policy: ArchiveEncryptionPolicyItem, parent: ArchiveEncryptionPolicyResponse["parent_policy"]): ArchiveEncryptionDraft {
|
||||
return {
|
||||
inheritMethods: policy.allowed_password_encryption_methods === undefined,
|
||||
methods: [...(policy.allowed_password_encryption_methods ?? parent.allowed_password_encryption_methods)],
|
||||
inheritChannels: policy.allowed_password_delivery_channels === undefined,
|
||||
channels: [...(policy.allowed_password_delivery_channels ?? parent.allowed_password_delivery_channels)]
|
||||
};
|
||||
}
|
||||
|
||||
export function buildPolicy(draft: ArchiveEncryptionDraft): ArchiveEncryptionPolicyItem {
|
||||
return {
|
||||
...(draft.inheritMethods ? {} : { allowed_password_encryption_methods: draft.methods }),
|
||||
...(draft.inheritChannels ? {} : { allowed_password_delivery_channels: draft.channels })
|
||||
};
|
||||
}
|
||||
|
||||
export function stable(value: ArchiveEncryptionPolicyItem): string {
|
||||
return JSON.stringify({
|
||||
methods: value.allowed_password_encryption_methods ? [...value.allowed_password_encryption_methods].sort() : null,
|
||||
channels: value.allowed_password_delivery_channels ? [...value.allowed_password_delivery_channels].sort() : null
|
||||
});
|
||||
}
|
||||
|
||||
/** System defaults are editable even before the first explicit override exists. */
|
||||
export function inheritedControlDisabled(scope: ArchiveEncryptionPolicyScope, inherited: boolean): boolean {
|
||||
return scope !== "system" && inherited;
|
||||
}
|
||||
|
||||
export function setDraftMethod(draft: ArchiveEncryptionDraft, method: ArchiveEncryptionMethod, checked: boolean): ArchiveEncryptionDraft {
|
||||
return { ...draft, inheritMethods: false, methods: toggle(draft.methods, method, checked) };
|
||||
}
|
||||
|
||||
export function setDraftChannel(draft: ArchiveEncryptionDraft, channel: PasswordDeliveryChannel, checked: boolean): ArchiveEncryptionDraft {
|
||||
return { ...draft, inheritChannels: false, channels: toggle(draft.channels, channel, checked) };
|
||||
}
|
||||
|
||||
function toggle<T extends string>(values: T[], value: T, checked: boolean): T[] {
|
||||
return checked ? Array.from(new Set([...values, value])) : values.filter((item) => item !== value);
|
||||
}
|
||||
+1
-1
@@ -79,7 +79,7 @@ const policyAdminSections: AdminSectionsUiCapability = {
|
||||
render: ({ settings, auth }) => createElement(ArchiveEncryptionPoliciesPanel, {
|
||||
settings,
|
||||
scopeType: "system",
|
||||
canWrite: hasScope(auth, "admin:policies:write")
|
||||
canWrite: hasScope(auth, "system:settings:write") && hasScope(auth, "admin:policies:write")
|
||||
})
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user