1001Ferramentas
🛂Security

Permissions-Policy Builder

Builds the Permissions-Policy header from a list of feature=allowlist entries (e.g. geolocation=()).



  

Switching off camera and GPS with a header

A third party iframe on your page can ask for camera, microphone or location, and the browser prompts the visitor as if the request came from you. Permissions-Policy, the successor to Feature-Policy, shuts that down at the source. What stops most people is the syntax, since feature=() with empty parentheses looks like a typo when it actually means an empty allowlist.

This page deserves an honest warning. The label asks for one feature per line, but the field is a single line input where you cannot type a line break at all. The code splits on newlines and joins with commas, so in practice it just prefixes Permissions-Policy: onto whatever you typed. Worse, the prefilled example contains literal \n sequences instead of real newlines, and those come straight through into the output. Clear the field and type a comma separated list.

The shape is feature=(allowlist). Empty parentheses deny it to everyone, (self) allows only your own origin, and (self "https://partner.com") allows yours plus one third party, double quotes included. A realistic line looks like geolocation=(), camera=(), microphone=(), fullscreen=(self), with no trailing comma. After you ship it, read the response headers in DevTools and exercise your iframes, since the policy is inherited by them. The string is built in your browser and nothing is uploaded.

Frequently asked questions

Why do backslash n sequences show up in the output?
That is a bug in the prefilled sample value, which contains literal \n instead of real line breaks. Clear the field and type your own comma separated list and the output is fine.
What is the difference between () and (self)?
Empty parentheses deny the feature to everyone, including your own page. (self) keeps it available on your origin while blocking it inside cross origin iframes.
Do I still need to send Feature-Policy as well?
In practice, no. Feature-Policy is the older name and current browsers read Permissions-Policy. Sending both mostly creates a risk that the two lists drift apart.

Related Tools