In FFLIB, a Domain enforces CRUD security and sharing rules by default. We use FFLIB Domains for implementing triggers. In the Salesforce standard, triggers run in system context, meaning they don't enforce CRUD security, and don't enforce sharing rules if "with sharing" is omitted from the class declaration. In almost every use case, we want to keep the Salesforce standard behaviour. For that, we reflected on the fact that triggers are fix business processes running in the background. They should run through regardless of what permissions the current user has. In addition, the user is often not even aware of these processes, so a trigger run that fails due to missing permissions would lead to an error message quite confusing to the user. So we are considering to patch fflib_SObjectDomain in our org to not enforce the permissions by default.
Our discussion lead us to the question: why does the FFLIB framework enforce CRUD security and sharing rules by default for Domains?
Your answer is highly appreciated and helps us, and the community, to better understand the security implications of the framework.
Best regards,
Daniel Wutz
total
field on a grand parent record. Check whether user has access for a transaction in triggers to avoid raising errors to users. In general, this method of doing things is easier to maintain (IMO).