Permissions-Policy header

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Want more browser support for this feature? Tell us why.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The HTTP Permissions-Policy response header provides a mechanism to allow and deny the use of browser features in a document or within any

To apply a policy to the current origin and others, you'd do this:

html

This is important: By default, if an

It is worth giving the src value a special mention. We mentioned above that using this allowlist value will mean that the associated feature will be allowed in this

Denying access to powerful features

SecureCorp Inc. wants to disable Microphone (for example MediaDevices.getUserMedia()) and Geolocation APIs in its application. It can do so using the following response header:

http
Permissions-Policy: microphone=(), geolocation=()

By specifying () for the origin list, the specified features will be disabled for all browsing contexts (this includes all

If a different origin ended up getting loaded into

Reporting violations

This example shows how to configure reporting of Permissions-Policy violations to a server endpoint.

The response headers below block geolocation and define the reporting endpoint name for the feature as "geo_endpoint". The Reporting-Endpoints HTTP response header is used to define the URL of this endpoint name.

http
Reporting-Endpoints: geo_endpoint="https://example.com/reports"
Permissions-Policy: geolocation=();report-to=geo_endpoint

Note: To send all violation reports to the same endpoint we might instead define the "default" reporting endpoint:

http
Reporting-Endpoints: default="https://example.com/reports"
Permissions-Policy: geolocation=()

A violation occurs when a page attempts to use the blocked feature, for example:

js
navigator.geolocation.getCurrentPosition(
  () => {},
  () => {},
);

The report payload sent to the endpoint might look like this:

json
[
  {
    "age": 48512,
    "body": {
      "columnNumber": 29,
      "disposition": "enforce",
      "lineNumber": 44,
      "message": "Permissions policy violation: geolocation access has been blocked because of a permissions policy applied to the current document.",
      "featureId": "geolocation",
      "sourceFile": "https://example.com/"
    },
    "type": "permissions-policy-violation",
    "url": "https://example.com/",
    "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36"
  }
]

Note: Chrome's server-side serialization of violation reports uses policyId rather than featureId for the feature name in the body of a server report. The PermissionsPolicyViolationReport returned by a ReportingObserver follows the specification.

Specifications

Specification
Permissions Policy
# permissions-policy-http-header-field

Browser compatibility

See also

Help improve MDN