User Access Policy rules

Hi! I’m using Directus 12.6.0 with PostgreSQL for a multi-business app.

Business owners/staff are the authenticated users. They create jobs for their business’s customers. Customers are CRM records—they aren’t creating jobs themselves.

Customers belong to a business, jobs belong to a customer, and memberships link business users to businesses. Read policies already restrict these users to customers in businesses where they have an active membership.

How do I restrict job creation to those same customers using access policies alone?

When a business user creates a job with “{“customer”: “”}”, does Directus check that customer’s Read permissions, or must this be enforced separately in Create validation?

A nested “customer.business.memberships” validation rule rejects even authorised requests with “customer: Value is required”, despite supplying the ID.

What is the correct schema/permission configuration to handle this natively, without Flows or hook extensions? Or what is the supported native approach to ensuring a submitted customer ID belongs to a business the current user can access?

1 Answer

1

Hey @David_O

No easy answer or solution for this without Flow/Hook/Endpoint. You could add an additional call to the frontend to populate the allowed customer options, but still won’t provide hard policy enforcement, just provides a good user experience when they use the app.

Short answer: you can’t do this with a nested validation rule, and Directus won’t check the customer’s Read permissions for you.

If you can share why a Flow or Hook is not an option, that would be helpful.

One option(Claude suggestion) you could try:
Denormalize business onto jobs and use a composite foreign key. Since validation can only see the payload, the business has to be in the payload. The database then guarantees that the customer and business agree.

Please note, I have never tried this and make no guarantees it would work. Keep us posted.