Skip to content

fix(intent): generate enforced default roles per entity - #6331

Merged
delchev merged 2 commits into
eclipse-dirigible:masterfrom
NicoleNG18:intent-default-roles-clean
Jul 21, 2026
Merged

fix(intent): generate enforced default roles per entity#6331
delchev merged 2 commits into
eclipse-dirigible:masterfrom
NicoleNG18:intent-default-roles-clean

Conversation

@NicoleNG18

Copy link
Copy Markdown
Contributor

Closes #6313

Problem

Apps generated from an app.intent had no enforced access control. Every generated REST controller was effectively open — any authenticated user could read and write every entity — and gen/.../roles/default-roles.roles came out as an empty [].

Root cause was upstream in the intent layer, not the templates: the downstream template-application-rest-java already emits per-operation checkPermissions() enforcement plus the default-roles.roles file, all keyed on the .model entity carrying generateDefaultRoles="true" + roleRead/roleWrite. But EdmIntentGenerator.entityDefaults() hardcoded generateDefaultRoles="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 persists roleRead/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>ReadOnly
  • roleWrite = <project>.<perspective>.<Entity>FullAccess

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 shared Settings shell grouping — consistent with how regular intent entities name their roles. PROJECTION entities stay unsecured (read-only). The generated .edm XML carries the three attributes as well, so a generated .edm opens 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/FullAccess roles 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; a PROJECTION entity stays generateDefaultRoles="false" with no roleRead.
  • IntentEngineIT (32/0/0): the generated .edm/.model carry generateDefaultRoles="true" + the role names, and the setting entity Country uses its own perspective (.Country.CountryReadOnly), not the Settings shell perspective.

Formatter and release-profile javadoc both pass on the touched module.

🤖 Generated with Claude Code

NicoleNG18 and others added 2 commits July 20, 2026 23:36
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>
@delchev
delchev merged commit 948aeb1 into eclipse-dirigible:master Jul 21, 2026
10 checks passed
@NicoleNG18
NicoleNG18 deleted the intent-default-roles-clean branch July 27, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intent generation cannot produce enforced per-entity access-control roles

2 participants