I know how to configure security model through OWD, Sharing Rules, Profiles and Roles in salesforce sandbox account but how to use Lightning Security Locker Service instead of OWD, Sharing Rules...etc

I am new to Lightning Locker Service. Can anybody help me on this.

3 Answers 3


how to use Lightning Security LockerService instead of OWD, Sharing Rules...etc

locker service provides a secure layer when lightning components are built enabling component encapsulation and other security features. The current API version is 43 any component built after API version 40 will have locker service enabled. you dont have to do anything explicit to enable it.

OWD and sharing rules are used to control record access for a user,group. It has nothing to do with locker service.


In general Lightning Locker Service is nothing you can enable/disable by yourself, it enforces enhanced security for Lightning Components automatically as long as you stick to the latest API version for your components.

So: if you don't have a good reason or just start with Lightning Components development go with the latest API version and enable all critical updates and you are ready to go.

More about Locker Service can be found here


Lightning Locker Service is not a feature you use - it is enforced by the system to limit the ability of one component's code to access other components on the page. I believe it's been enforced since the Winter 17 release, and does not need to be enabled manually. LockerService is always on - you cannot turn it off. The most important thing to remember is that it blocks access to anything outside your component scope - you can't access the document body, other components, etc.

The technical details are explained here: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/security_code.htm

Any lightning components you create with a version above 40 enforces locker service and below 40 doesn’t locker service doesn’t get enforced. Earlier it used to be part of critical update but now was defined based on you lightning component bundle version. You change yourself bundle version to turn the locker service on and off. locker service has nothing to do with profiles and permission, when said about security locker service is a wrapper around the lightning that checks for security vulnerabilities and makes sure developers always follow coding best practices.

please read the below blog for more info on locker service: https://developer.salesforce.com/blogs/developer-relations/2016/04/introducing-lockerservice-lightning-components.html

Locker service enforces some of the java-script security best practices and helps component isolation by ensuring they are not able to see and edit each other’s attributes both in same and different namespace. Locker uses browser CSP (Content Security Policy) to prevent a web page against cross-site scripting (XSS), clickjacking and other code injection attacks resulting from execution of malicious content in the trusted web page context.

Locker Service is a powerful security architecture for Lightning components. Locker Service enhances security by isolating Lightning components in their own namespace. Locker Service also promotes best practices that improve the supportability of your code by only allowing access to supported APIs and eliminating access to non-published framework internals. how to know it is using with locker service or not in lightning components Any new component created now in your salesforce org will be with version 43 and any lightning component create with Api version 40 and higher will have locker service enabled.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .