Skip to content

AB#129134 use-user-context-in-permissions#1227

Open
GhaziAlibi wants to merge 3 commits intonextfrom
AB#129134-use-user-context-in-permissions
Open

AB#129134 use-user-context-in-permissions#1227
GhaziAlibi wants to merge 3 commits intonextfrom
AB#129134-use-user-context-in-permissions

Conversation

@GhaziAlibi
Copy link
Copy Markdown

Description

This PR adds support for literal values in role resource access filters.

For attribute filters, eq and neq can now compare either to another field or to a typed value. Text operators like contains, starts with, and ends with also work with attribute filters. On the backend, permission filters now correctly handle these literal attribute comparisons using the current user’s attributes.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Ran frontend checks with eslint and tsc --noEmit, and ran the backend unit test tests/unit-tests/utils/filter/getFormPermissionFilter.spec.ts.

  • verified manually in Back Office -> Settings -> Roles -> Resources that attribute filters can switch between Field and Value, save correctly, and enforce access as expected.

Screenshots

image image image

Checklist:

( * == Mandatory )

  • * I have set myself as assignee of the pull request
  • * My code follows the style guidelines of this project
  • * Linting does not generate new warnings
  • * I have performed a self-review of my own code
  • * I have put the ticket for review, adding the oort-backend team to the list of reviewers
  • * I have commented my code, particularly in hard-to-understand areas
  • * I have put JSDoc comment in all required places
  • * My changes generate no new warnings
  • * I have included screenshots describing my changes if relevant
  • * I have selected labels in the Pull Request, according to the changes with code brings
  • I have made corresponding changes to the documentation ( if required )
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

More explanation

https://www.loom.com/share/05a716d61b9744faaf51fb304c21d1e5?sid=f87cf896-582a-4f76-93ae-8ceed801b145

@GhaziAlibi GhaziAlibi requested review from a team and Copilot April 15, 2026 12:58
@GhaziAlibi GhaziAlibi self-assigned this Apr 15, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends role/resource access filtering to support comparing $attribute.* values against typed literal values (in addition to comparing against another record field), and ensures backend permission filters evaluate these comparisons using the current user’s attributes.

Changes:

  • Added backend support for literal comparisons (including text operators) on $attribute.* filters by pre-evaluating them into match-all / match-none Mongo predicates.
  • Updated permission-filter generation to pass the current user into getFilter so attribute filters can be resolved.
  • Added unit tests covering attribute-to-field vs attribute-to-literal behavior in getFormPermissionFilter.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/utils/schema/resolvers/Query/getFilter.ts Adds literal attribute evaluation and routes attribute filters to either literal evaluation or record-field comparison.
src/utils/filter/getFormPermissionFilter.ts Passes user into getFilter context so $attribute.* filters can resolve against current user attributes.
__tests__/unit-tests/utils/filter/getFormPermissionFilter.spec.ts Adds unit tests for attribute filter behavior (field vs literal, match-all/match-none outcomes).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils/schema/resolvers/Query/getFilter.ts
Comment thread src/utils/schema/resolvers/Query/getFilter.ts Outdated
@GhaziAlibi GhaziAlibi changed the title feat: support literal values in attribute access filters AB#129134-use-user-context-in-permissions Apr 16, 2026
@GhaziAlibi GhaziAlibi changed the title AB#129134-use-user-context-in-permissions AB#129134 use-user-context-in-permissions Apr 16, 2026
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.

2 participants