Feature Request: Support for Custom Properties in Policy Rule Conditions
Is your feature request related to a problem? Please describe. I am frustrated by the current limitation of the Policy engine where Rule conditions can only evaluate a predefined set of entity attributes. Currently, if we have Custom Properties defined on an Entity (e.g., a "Data Sensitivity" dropdown or a "Department Owner" field on a Table), we cannot reference these properties within the SpEL expression of a Policy Rule.
This forces us to create overly broad roles or manually manage access via Tags, rather than using the powerful attribute-based access control (ABAC) that OpenMetadata aims to provide.
Describe the solution you'd like I would like the OpenMetadata Policy engine to expose Custom Properties within the SpEL evaluation context.
Specifically:
Allow the resource object in a Rule condition to access its custom properties (e.g., resource.customProperties.get('propertyName')).
Ideally, provide a helper method to simplify the syntax, such as matchCustomProperty('propertyName', 'value').
Ensure that when a Rule is being validated or saved, the UI/Backend recognizes these custom fields as valid variables.
hi sir I’ve reviewed the issue and have an idea for the fix. I’d like to work on this. Please assign it to me.
Hi @m0hitbansal @harshach ! I'd love to work on this feature — could you assign it to me? Thanks!
@m0hitbansal please can you assign this issue so I can take forward a chance.
Hi @pmbrull @harshach 👋
Submitted a fix in PR #27218
Implemented all three requested features:
getCustomProperties()— exposes entity custom properties asMap<String, Object>in SpEL contextmatchCustomProperty('propertyName', 'value')— convenient boolean helper for policy rule conditionsFIELD_EXTENSIONis now fetched during entity resolution so custom properties are loaded from DB
Policy rules can now use:
matchCustomProperty('dataSensitivity', 'PII')
resource.customProperties.get('department') == 'Finance'
Hi @m0hitbansal, I'd like to take this one in the hackathon. I've reviewed the open PRs (#27033, #27218) - both attempt the same approach but have correctness gaps:
- #27033 always adds
FIELD_EXTENSIONto fetched fields (breaks entity types wheresupportsExtension == false), and usesinstanceof Maponentity.getExtension()which is actually a JacksonObjectNode- so it returns empty even when properties exist. The bot comments capture this, but haven't been addressed since Apr 4. - #27218 is closer but uses bare
@Functionannotations on the new helpers.Function.javarequiresname/input/description/examples(no defaults), andExpressionValidatorbuilds its allow-list fromannotation.name()- so the new helpers won't passparseExpressionvalidation, won't appear in the UI's/policies/functionsdropdown, and the new tests will fail once CI runs.
My plan:
- Add
getCustomProperties()toResourceContextInterface(default empty map), implement inResourceContextwith lazy caching, gate theFIELD_EXTENSIONfield-add onentityRepository.isSupportsExtension(), and convert viaJsonUtils.convertValue(...). - Add three properly-annotated SpEL helpers on
RuleEvaluator:matchCustomProperty(name, value),matchAnyCustomProperty(name, values...),hasCustomProperty(name). Full@Functionmetadata so they auto-appear in the rule editor. - Unit tests through
parseExpression(validates the allow-list path), plus an integration test that creates a custom property, attaches a policy withmatchCustomProperty, and asserts the authorization decision end-to-end.
Please assign me if no one is actively addressing the above.
Hi @m0hitbansal , I'd like to work on this. My approach: locate the SpEL evaluation context builder in the policy/authorization service, expose the entity's customProperties map on the resource object, and add a helper method matchCustomProperty('name', 'value') for clean rule syntax. Will also check if the frontend rule condition validator needs updating. Can you assign this to me?
Thank you everyone for your interest in this issue, but it has been assigned. We will reopen this issue if necessary