fix(intent): generate enforced default roles per entity - #6331
Merged
delchev merged 2 commits intoJul 21, 2026
Conversation
EdmIntentGenerator hardcoded generateDefaultRoles="false" and never wrote roleRead/roleWrite, so intent-generated apps had no access control: every generated REST controller was open and default-roles.roles was empty. Emit generateDefaultRoles="true" plus the standard <project>.<perspective>.<Entity>ReadOnly / FullAccess role names for every real (controller-backed) entity, mirroring the EDM editor's "Generate Default Roles" checkbox. The perspective segment is the entity's resolved perspective (resolvePerspective): its own name for a top-level entity, its parent's for a composition child, and its own name for a setting too (never the "Settings" shell grouping) - consistent with how regular entities name their roles. The downstream template-application-rest-java template already consumes this metadata to emit checkPermissions() and default-roles.roles; no template change is needed. PROJECTION entities stay unsecured (read-only). The .edm XML carries the attributes too so a generated .edm opens with the box checked. Covered by EdmIntentGeneratorTest (regular + setting entity role names, PROJECTION-stays-false) and IntentEngineIT (model/edm role assertions incl. the setting entity not using the Settings perspective). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…eNG18/dirigible into intent-default-roles-clean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6313
Problem
Apps generated from an
app.intenthad no enforced access control. Every generated REST controller was effectively open — any authenticated user could read and write every entity — andgen/.../roles/default-roles.rolescame out as an empty[].Root cause was upstream in the intent layer, not the templates: the downstream
template-application-rest-javaalready emits per-operationcheckPermissions()enforcement plus thedefault-roles.rolesfile, all keyed on the.modelentity carryinggenerateDefaultRoles="true"+roleRead/roleWrite. ButEdmIntentGenerator.entityDefaults()hardcodedgenerateDefaultRoles="false"and never wrote the role names, so the template was fed empty role data.(Verified: the flag alone is inert — nothing in
service-generate/the templates derives the role names from it; the EDM editor's "Generate Default Roles" checkbox works precisely because it also persistsroleRead/roleWrite.)Fix
In
EdmIntentGenerator, generate the roles exactly like modeling an entity in the EDM editor with "Generate Default Roles" checked, for every real (controller-backed) entity:generateDefaultRoles="true"roleRead = <project>.<perspective>.<Entity>ReadOnlyroleWrite = <project>.<perspective>.<Entity>FullAccessThe perspective segment is the entity's resolved perspective (
resolvePerspective): its own name for a top-level entity, its parent's for a composition child, and its own name for a setting too — never the sharedSettingsshell grouping — consistent with how regular intent entities name their roles.PROJECTIONentities stay unsecured (read-only). The generated.edmXML carries the three attributes as well, so a generated.edmopens in the EDM editor with the box checked.No template change is required — the rest-java controller template and the AngularJS/Harmonia perspective templates already consume this metadata.
Behavior change
Generated apps are now secure by default (parity with the EDM checkbox): an administrator assigns the generated
<Entity>ReadOnly/FullAccessroles to users. Super-role / anonymous-mode handling is unchanged.Tests
EdmIntentGeneratorTest(18/0/0): a regular entity (library.Book.BookReadOnly) and a setting entity (library.Genre.GenreReadOnly,perspectiveName="Settings") both carry the roles; aPROJECTIONentity staysgenerateDefaultRoles="false"with noroleRead.IntentEngineIT(32/0/0): the generated.edm/.modelcarrygenerateDefaultRoles="true"+ the role names, and the setting entityCountryuses its own perspective (.Country.CountryReadOnly), not theSettingsshell perspective.Formatter and release-profile javadoc both pass on the touched module.
🤖 Generated with Claude Code