Skip to content

Commit 36310b9

Browse files
committed
Add Permissions-Policy header
Ref h5bp/server-configs-apache#179
1 parent 8600df1 commit 36310b9

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

h5bp/security/permissions-policy.conf

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# ----------------------------------------------------------------------
2+
# | Permissions Policy |
3+
# ----------------------------------------------------------------------
4+
5+
# Set a strict Permissions Policy to mitigate access to browser features.
6+
#
7+
# The header uses a structured syntax, and allows sites to more tightly
8+
# restrict which origins can be granted access to features.
9+
# The list of available features: https://github.com/w3c/webappsec-permissions-policy/blob/main/features.md
10+
#
11+
# The example policy below aims to disable all features expect synchronous
12+
# `XMLHttpRequest` requests on the same origin.
13+
#
14+
# To check your Permissions Policy, you can use an online service, such as:
15+
# https://securityheaders.com/
16+
# https://observatory.mozilla.org/
17+
#
18+
# https://www.w3.org/TR/permissions-policy-1/
19+
# https://owasp.org/www-project-secure-headers/#permissions-policy
20+
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy
21+
# https://scotthelme.co.uk/a-new-security-header-feature-policy/
22+
23+
add_header Permissions-Policy $permissions_policy always;

nginx.conf

+7-1
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,14 @@ http {
108108
~*text/(html|javascript)|application/pdf|xml "default-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'; object-src 'none'; upgrade-insecure-requests";
109109
}
110110

111+
# Add Permissions-Policy for HTML documents.
112+
# h5bp/security/permissions-policy.conf
113+
map $sent_http_content_type $permissions_policy {
114+
~*text/(html|javascript)|application/pdf|xml "accelerometer=(),autoplay=(),camera=(),display-capture=(),document-domain=(),encrypted-media=(),fullscreen=(),geolocation=(),gyroscope=(),magnetometer=(),microphone=(),midi=(),payment=(),picture-in-picture=(),publickey-credentials-get=(),screen-wake-lock=(),sync-xhr=(self),usb=(),web-share=(),xr-spatial-tracking=()";
115+
}
116+
111117
# Add Referrer-Policy for HTML documents.
112-
# h5bp/security/referrer-policy.conf.conf
118+
# h5bp/security/referrer-policy.conf
113119
map $sent_http_content_type $referrer_policy {
114120
~*text/(css|html|javascript)|application\/pdf|xml "strict-origin-when-cross-origin";
115121
}

0 commit comments

Comments
 (0)