Skip to content

Commit d75e262

Browse files
authored
Merge pull request #2424 from beyonnex-io/feature/simplify-policy-import-references
Simplify policy import model: replace entriesAdditions and importsAliases with entry-level references
2 parents 40f6cd1 + ec66f44 commit d75e262

228 files changed

Lines changed: 7981 additions & 18759 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

base/service/src/main/java/org/eclipse/ditto/base/service/signaltransformer/placeholdersubstitution/AbstractTypedSubstitutionStrategy.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ protected static PolicyEntry substitutePolicyEntry(final PolicyEntry existingPol
7676
substitutedSubjects, existingPolicyEntry.getResources(),
7777
existingPolicyEntry.getNamespaces().orElse(null),
7878
existingPolicyEntry.getImportableType(),
79-
existingPolicyEntry.getAllowedImportAdditions().orElse(null));
79+
existingPolicyEntry.getAllowedAdditions().orElse(null),
80+
existingPolicyEntry.getReferences().isEmpty() ? null : existingPolicyEntry.getReferences());
8081
}
8182

8283
return resultEntry;

documentation/src/main/resources/jsonschema/policy.json

Lines changed: 24 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,10 @@
2828
},
2929
"maxItems": 10
3030
},
31-
"entriesAdditions": {
32-
"title": "Entries additions",
33-
"type": "object",
34-
"description": "Additional subjects and/or resources to additively merge into imported policy entries. Each key is a label of an imported policy entry. The value is an object with optional \"subjects\" and/or \"resources\" and/or \"namespaces\" fields that will be merged into the corresponding imported entry. The imported policy entry must explicitly allow these additions via its \"allowedImportAdditions\" field, otherwise the additions are rejected.",
35-
"additionalProperties": {
36-
"title": "EntryAddition",
37-
"type": "object",
38-
"description": "Defines additional subjects and/or resources to be merged into a single imported policy entry.",
39-
"properties": {
40-
"subjects": {
41-
"title": "Subjects",
42-
"type": "object",
43-
"description": "Additional subjects to merge into the imported entry."
44-
},
45-
"resources": {
46-
"title": "Resources",
47-
"type": "object",
48-
"description": "Additional resources to merge into the imported entry."
49-
},
50-
"namespaces": {
51-
"title": "Namespaces",
52-
"type": "array",
53-
"description": "Additional namespaces to merge into the imported entry",
54-
"items": {
55-
"type": "string"
56-
}
57-
}
58-
}
59-
}
60-
},
6131
"transitiveImports": {
6232
"title": "Transitive imports",
6333
"type": "array",
64-
"description": "List of policy IDs from the imported policy's own imports that should be resolved transitively before extracting entries. This enables multi-level import chains where a template policy defines resources and an intermediate policy adds subjects via entriesAdditions.",
34+
"description": "List of policy IDs from the imported policy's own imports that should be resolved transitively before extracting entries. This enables multi-level import chains where an intermediate policy defines entries with references pointing to a template policy's entries.",
6535
"items": {
6636
"type": "string",
6737
"description": "Policy ID of a policy that the imported policy itself imports from."
@@ -71,40 +41,6 @@
7141
}
7242
}
7343
},
74-
"importsAliases": {
75-
"title": "ImportsAliases",
76-
"type": "object",
77-
"description": "Imports aliases mapping a label to one or more entries additions targets. Subject operations on the alias label via /entries/{label}/subjects are transparently fanned out to all referenced targets. A label must not exist as both an imports alias and a local policy entry.",
78-
"additionalProperties": {
79-
"title": "ImportsAlias",
80-
"type": "object",
81-
"description": "A single imports alias defining the targets to fan out subject operations to.",
82-
"properties": {
83-
"targets": {
84-
"title": "Targets",
85-
"type": "array",
86-
"description": "List of entries additions targets this alias fans out to.",
87-
"items": {
88-
"title": "ImportsAliasTarget",
89-
"type": "object",
90-
"description": "A target reference pointing to a specific entry addition in a policy import.",
91-
"properties": {
92-
"import": {
93-
"type": "string",
94-
"description": "The policy ID of the import this target refers to."
95-
},
96-
"entry": {
97-
"type": "string",
98-
"description": "The label of the entry within the import's entriesAdditions."
99-
}
100-
},
101-
"required": ["import", "entry"]
102-
}
103-
}
104-
},
105-
"required": ["targets"]
106-
}
107-
},
10844
"entries": {
10945
"title": "PolicyEntries",
11046
"type": "object",
@@ -236,21 +172,37 @@
236172
"enum": ["implicit", "explicit", "never"],
237173
"default": "implicit"
238174
},
239-
"allowedImportAdditions": {
175+
"references": {
176+
"title": "References",
177+
"type": "array",
178+
"description": "An optional list of references to other policy entries. Each reference points to an entry either in the same policy (local reference) or in an imported policy (import reference). When set, subjects, resources, and namespaces from the referenced entries are additively merged into this entry.",
179+
"items": {
180+
"type": "object",
181+
"description": "A single reference to a policy entry.",
182+
"properties": {
183+
"entry": {
184+
"type": "string",
185+
"description": "The label of the referenced entry."
186+
},
187+
"import": {
188+
"type": "string",
189+
"description": "The ID of the imported policy. If absent, the reference points to a local entry within the same policy."
190+
}
191+
},
192+
"required": ["entry"]
193+
}
194+
},
195+
"allowedAdditions": {
240196
"title": "Allowed import additions",
241197
"type": "array",
242-
"description": "Defines which types of additions are allowed when this entry is imported by other policies via `entriesAdditions`. If omitted or empty, no additions are allowed. This default ensures that existing policies cannot be extended with additional subjects or resources unless the policy author explicitly opts in.",
198+
"description": "Defines which types of additions are allowed when this entry is referenced by other entries via `references`. Semantics: field absent (omitted) means no restriction — the referencing entry's own subjects, resources, and namespaces merge in as usual (upgrade-friendly default for pre-existing entries); field present and explicitly empty (`[]`) means no additions are allowed (only this entry's content is effective on the referencing side); field present with values means only the listed kinds of additions survive on the referencing entry. Enforced at resolution time as a runtime filter, not as a write-time contract: disallowed own additions on referencing entries are silently stripped at enforcement, not rejected at write. The same filter applies whether the reference is local or an import reference.",
243199
"items": {
244200
"type": "string",
245201
"enum": ["subjects", "resources", "namespaces"]
246202
},
247203
"example": ["subjects"]
248204
}
249-
},
250-
"required": [
251-
"subjects",
252-
"resources"
253-
]
205+
}
254206
}
255207
}
256208
},

0 commit comments

Comments
 (0)