Use with sharing for @AuraEnabled Apex Controllers with Implicit Sharing (Update, Postponed)
Where: This change applies to Aura and Lightning web components in Lightning Experience, Salesforce Classic, Lightning communities, and all versions of the Salesforce app.
When: This update is enforced when a sandbox or production org is upgraded to Spring ’21. Enforcement starts for some sandboxes on November 29, 2020. To get the major release upgrade date for your instance, go to Trust Status, search for your instance, and click the maintenance tab.
Why: An @AuraEnabled Apex class that doesn’t explicitly set with sharing or without sharing uses a default or implicit value of with sharing. The purpose of the retired Use without sharing for @AuraEnabled Apex Controllers with Implicit Sharing update was to make Apex controllers for Aura components default to without sharing. This behavior made Apex controllers consistent in Aura components and Visualforce pages.
After further consideration, we decided to ensure that Lightning components are secure by default. So we created this new update that defaults to with sharing for @AuraEnabled Apex classes used by Aura components or Lightning web components.
Apex classes generally run in system mode. Consequently, the current user’s credentials aren’t used to execute Apex logic, and the user’s permissions and field-level security aren’t automatically applied.
You can choose whether an Apex class enforces sharing rules by using the with sharing or without sharing keywords. Enforcing sharing rules by using the with sharing keyword doesn’t enforce the user’s permissions and field-level security. You must manually enforce CRUD permissions and field-level security separately in your Apex classes.
How: The best way to prepare for this update is to ensure that all your @AuraEnabled Apex code explicitly controls sharing behavior using the with sharing or without sharing keywords. If all your @AuraEnabled code explicitly sets sharing behavior, this update has no effect.
To test this update, we recommend working in a sandbox. After November 29, 2020, you can continue to activate or deactivate the update from Release Updates in Setup until the update is automatically enforced when your org is upgraded to Spring ’21.
- From Setup, enter Release Updates in the Quick Find box.
- Select Release Updates.
- Find Use with sharing for @AuraEnabled Apex Controllers with Implicit Sharing, and click View Details or Get Started.
- Test the behavior of components that use Apex classes that don’t include the with sharing or without sharing keywords.