Salesforce.com:Developing Secure Code in Salesforce Lightning

Developing Secure Code

The Salesforce Aura framework uses Content Security Policy (CSP) to control the source of content that can be loaded on a page. The LockerService architectural layer enhances security by isolating individual Lightning components in their own containers and enforcing coding best practices.
The Lightning Component framework uses Content Security Policy (CSP) to control the source of content that can be loaded on a page.
CSP is a Candidate Recommendation of the W3C working group on Web Application Security. The framework uses the Content-​Security-​Policy HTTP header recommended by the W3C.
The framework’s CSP covers these resources:
JavaScript LibrariesAll JavaScript libraries must be uploaded to Salesforce static resources. For more information, see Using External JavaScript Libraries.HTTPS Connections for ResourcesAll external fonts, images, frames, and CSS must use an HTTPS URL.
You can change the CSP policy and expand access to third-party resources by adding CSP Trusted Sites.

Content Security Policy and LockerService

LockerService tightens CSP to eliminate the possibility of cross-site scripting attacks. These CSP changes are only enforced in sandboxes and Developer Edition orgs.
The stricter CSP disallows the unsafe-inline and unsafe-eval keywords for inline scripts (script-src). Ensure that your code and third-party libraries you use adhere to these rules by removing all calls using eval() or inline JavaScript code execution. You might have to update your third-party libraries to modern versions that don’t depend on unsafe-inline or unsafe-eval.
LockerService is a critical update for this release. LockerService will be automatically activated for all orgs in the Summer ’17 release. Before the Summer ’17 release, you can manually activate and deactivate the update as often as you need to evaluate the impact on your org.

Browser Support

CSP isn’t enforced by all browsers. For a list of browsers that enforce CSP, see caniuse.com
 
 

Comments

Popular posts from this blog

Salesforce.com: Expression Operators in Salesforce lightning Components

Custom Calendar on VisualForce Page

Salesforce.com: Scheduled Apex