Everything you'd want to know before you install.
A detailed look at how PrestaShop Security Headers: CSP, HSTS and an A+ Grade Without Server Access works, why we built it the way we did, and the thinking behind the features above.
Why a CSP is delicate on a shop
A Content-Security-Policy decides which scripts, styles, images and frames a page may load. Too loose, it lets an injected script run; too strict, it blocks the payment form, the tracking or the chat. PrestaShop themes and modules also print inline scripts, which a strict policy forbids. The module therefore starts from a policy compatible with the shop and lets the browsers tell you what it would block before anything is blocked.
Observation first
The setup assistant analyzes the home page, pre-selects the services it detects and starts an observation period in Report-Only. Your visitors' browsers report what the policy would block, the reports are grouped by directive and source, and each one comes with a suggestion: enable the matching service, allow the domain, or the right fix for inline code. Your own devices, declared by IP or through a test link, already get the blocking policy.
What the nonce does, and what it does not
A new random nonce is added on every page to the scripts written by the shop and to scripts from allowed hosts, and unsafe-inline is removed from script-src. A script from an unknown host, or a script tag whose text comes from the request, does not get it. Its limit is stated in the back office: a script stored in the database, for example in a product description, is part of the page and gets the nonce, which is why PrestaShop's HTMLPurifier option should stay on.
Going live, and coming back
When the reports are handled, the assistant switches the CSP to blocking for every visitor. An optional safety net watches the next 48 hours and goes back to Report-Only by itself if new blocks hit several visitors. Every change is a revision with its author and an optional note, comparable and restorable in one click, and an emergency stop by file, constant or command line works even if the back office is unreachable.
From PrestaShop or from the server
Headers are sent by PHP at the very start of each request, with no server change. If you prefer the server to send the static ones, the module generates Apache and nginx blocks that remove the copies sent by PHP and only send HSTS over https, then keeps sending only the CSP. The scanner checks the result on the shop's own pages and flags duplicates and version leaks; its score is indicative and public scanners may grade differently.
There are no reviews yet.