Skip to content

Child record list widgets should have NOT_PROTECTED permission rules by default #357

@KofTwentyTwo

Description

@KofTwentyTwo

Problem

When an application sets restrictive default permission rules (e.g., READ_INSERT_EDIT_DELETE_PERMISSIONS with DenyBehavior.HIDDEN), child record list widgets created by ChildRecordListWidgetFromRecordEntityGenericMetaDataProducer get filtered out in MetaDataAction because they have null permission rules.

Root Cause

ChildRecordListRenderer.widgetMetaDataBuilder() creates a QWidgetMetaData but does not set permissionRules. When PermissionsHelper.getEffectivePermissionRules() is called for these widgets, it returns the instance's default permission rules (line 467):

if(metaDataWithPermissionRules.getPermissionRules() == null)
{
   LOG.warn("Null permission rules on meta data object...");
   return (instance.getDefaultPermissionRules());
}

If those default rules are restrictive and the user doesn't have the required permissions, the widget gets filtered out in MetaDataAction at line 180-184.

Suggested Fix

Set NOT_PROTECTED permission rules on child record list widgets by default in ChildRecordListRenderer.widgetMetaDataBuilder():

public static Builder widgetMetaDataBuilder(QJoinMetaData join)
{
   return (new Builder(new QWidgetMetaData()
      .withName(join.getName())
      .withIsCard(true)
      .withCodeReference(new QCodeReference(ChildRecordListRenderer.class))
      .withType(WidgetType.CHILD_RECORD_LIST.getType())
      .withDefaultValue("joinName", join.getName())
      .withValidatorPlugin(new ChildRecordListWidgetValidator())
      .withPermissionRules(new QPermissionRules().withLevel(PermissionLevel.NOT_PROTECTED))  // ADD THIS
   ));
}

This makes sense because:

  1. Child record list widgets are displayed within a parent record's detail page
  2. Access to the parent record already requires permissions on the parent table
  3. The widget queries the child table, which has its own permission checks
  4. The widget itself doesn't need additional permission gating

Workaround

Applications can work around this by adding a post-processor that sets permission rules on widgets with null rules:

qInstance.getWidgets().values().forEach(widget -> {
   if(widget.getPermissionRules() == null) {
      widget.setPermissionRules(new QPermissionRules()
         .withLevel(PermissionLevel.NOT_PROTECTED));
   }
});

Environment

  • QQQ version: 0.40.0-SNAPSHOT

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions