Closed chazwatkins closed 1 year ago
Hi @chazwatkins -- thank you for the contribution. However, there is already a branch that has undergone some peer review and is nearly ready for merge to support User Mode. It also addresses a longstanding performance issue with QueryFactory so while a lot of your work overlaps the work on #419 (PR #420), your efforts don't go as far as the other proposal.
I'm going to close this out and would request that you participate in the review of PR #420
@daveespo The other PR has been open for nearly five months. When will it be merged?
I'm fine with contributing to the other PR instead. I'll port my API to your version.
Goal
Add support for
USER_MODE
andSYSTEM_MODE
database operation modes to fflib_QueryFactory and fflib_SObjectSelector that provides backward compatibility with the existingenforceFLS
andenforceCRUD
checks.fflib_QueryFactory
When the operation mode is set, the
enforceFLS
is set to false to skip the fflib_SecurityUtils checks. Alternatively, when you callsetEnforceFLS(true)
, the operation mode is set to null, and fflib_SecurityUtils checks are respected.Operation Mode not set
Specify
WITH USER_MODE
Specify
WITH SYSTEM_MODE
Salesforce uses
SYSTEM_MODE
as the default operation mode when not specified in the query.withSystemMode()
allows users to make their queries explicit if desired.Works with other clauses
The `WITH {OPERATION_MODE}' clause is inserted after the WHERE clause and before any other clauses
Only applies to top-level queries
fflib_SObjectSelector
isEnforcingFLS()
andisEnforcingCRUD()
now consider the operation mode to determine their result instead of directly returning the values ofm_enforceFLS
andm_enforceCRUD
. This allows the user to get the correct state from the methods, regardless if they are using legacy enforcement or one of the new operation modes.When the operation mode is set, the
m_enforceFLS
andm_enforceCRUD
are false.Operation Mode not set
isEnforcingFLS()
andisEnforcingCRUD()
returns the value of the private properties. fflib_SecurityUtils checks are respected.Specify
USER_MODE
isEnforcingFLS()
andisEnforcingCRUD()
return true, but the properties are false. fflib_SecurityUtils checks are skipped.Specify
SYSTEM_MODE
isEnforcingFLS()
andisEnforcingCRUD()
return false, and the properties are set to false. fflib_SecurityUtils checks are skipped.Add
Enum fflib_SecurityUtils.OperationMode
fflib_QueryFactory
fflib_SObjectSelector
Change
fflib_QueryFactoryTest
fflib_SObjectSelector
m_enforceFLS
to use getter/setter so when its value is changed to true, then theoperationMode
property will be set to nullfflib_SObjectSelectorTest
This change is![Reviewable](https://reviewable.io/review_button.svg)