How to add a Permissions-Policy header
Send a Permissions-Policy that switches off browser features the site does not use, such as camera, microphone and location.
Last reviewed
Why it matters
If a third-party script or embedded frame misbehaves, it can ask visitors for camera, microphone or location access under your site's name. A Permissions-Policy turns off the features the site does not use, for the page and every frame in it, so those prompts cannot appear.
How to fix it
A minimal start:
camera=(), microphone=(), geolocation=()
() turns the feature off for the page and every frame, including the site's own scripts. Before using it, check the site does not need these itself: store locators and "near me" maps (location), video calls, voice search or dictation, QR or ID scanners. If it does, use (self) for that feature, for example geolocation=(self), or list a provider in quotes, geolocation=(self "https://maps.example.net"). Not every major browser enforces this header yet.
Replace the highlighted values: www.example.com with the site's hostname.
Cloudflare
Rules > Overview > Create rule > Response Header Transform Rule, name it, apply it to all incoming requests, choose Set static with Header name Permissions-Policy and Value camera=(), microphone=(), geolocation=(), and Deploy.
Source: create a response header rule.
nginx
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
Source: ngx_http_headers_module.
Apache
<IfModule mod_headers.c>
Header always set Permissions-Policy "camera=(), microphone=(), geolocation=()"
</IfModule>
Source: mod_headers.
Caddy
The quotes are needed because the value has spaces:
header Permissions-Policy "camera=(), microphone=(), geolocation=()"
Source: the header directive.
Vercel
{
"headers": [
{
"source": "/(.*)",
"headers": [{ "key": "Permissions-Policy", "value": "camera=(), microphone=(), geolocation=()" }]
}
]
}
Source: vercel.json.
Netlify
/*
Permissions-Policy: camera=(), microphone=(), geolocation=()
Source: Netlify custom headers.
WordPress
Plugin route (HTTP Headers): Settings > HTTP Headers > Security, Edit next to Permissions-Policy, select On, tick camera, microphone and geolocation and set each to none, and Save Changes.
Code route: inside the send_headers function in wp-content/mu-plugins/security-headers.php (see the HSTS guide for the file):
header( 'Permissions-Policy: camera=(), microphone=(), geolocation=()' );
Sources: HTTP Headers plugin, send_headers.
Shopify
Shopify documents no way for merchants to set response headers, and storefronts do not send this one, so the finding can appear with no setting to change it. Accepting it in Owl Keeper is reasonable.
Check that it worked
curl -sI https://www.example.com/ | grep -i permissions-policy
In a Chromium browser, run navigator.geolocation.getCurrentPosition(console.log, console.error) in the console on the site: it should fail at once with a permissions-policy error and no prompt. Test the site's own map, chat or video features too, then run the Owl Keeper Security headers check again.
Test it now with the free HTTP status code checker. No account needed.
What can go wrong
- It blocks the site's own use of the features, silently: a store locator, a "use my location" button, a video consultation or a barcode scanner simply stops working, with no prompt. Ask the client or search the theme and plugins first.
- A syntax error can make the browser ignore the whole policy: check the console after deploying.