Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ambient-light-sensor=() Fix browser warning: Error with Permissions-Policy header: Unrecognized feature: 'ambient-light-sensor'. #203

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ As described in the [OWASP guidance](https://cheatsheetseries.owasp.org/cheatshe
* `X-Frame-Options: Deny`
* `Content-Security-Policy: default-src: none; frame-ancestors 'none'`
* `Referrer-Policy: no-referrer`
* `Permissions-Policy: accelerometer=(), ambient-light-sensor=(), autoplay=(), camera=(), display-capture=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()`
* `Permissions-Policy: accelerometer=(), autoplay=(), camera=(), display-capture=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()`

Apply it in the same way to your header policy collection:

Expand Down Expand Up @@ -449,10 +449,6 @@ public void Configure(IApplicationBuilder app)
.Self()
.For("http://testUrl.com");

builder.AddAmbientLightSensor() // ambient-light-sensor 'self' http://testUrl.com
.Self()
.For("http://testUrl.com");

builder.AddAutoplay() // autoplay 'self'
.Self();

Expand Down Expand Up @@ -523,7 +519,7 @@ var policyCollection = new HeaderPolicyCollection()
This applies a "secure" policy based on the [suggested by OWASP for APIs](https://cheatsheetseries.owasp.org/cheatsheets/REST_Security_Cheat_Sheet.html#security-headers):

```HTTP
Permissions-Policy: accelerometer=(), ambient-light-sensor=(), autoplay=(), camera=(), display-capture=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()
Permissions-Policy: accelerometer=(), autoplay=(), camera=(), display-capture=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()
```

Alternatively, if you want to relax some of these directives, you can use the builder version:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ public PermissionsPolicyBuilder AddDefaultSecureDirectives()
{
// https://github.com/w3c/webappsec-permissions-policy/blob/f15a4548691ea69a87227c0f67571da2cc0e08c1/features.md?plain=1#L19
AddAccelerometer().None();
AddAmbientLightSensor().None();
AddAutoplay().None();

// AddBattery().None(); // Request: https://issues.chromium.org/issues/40100229
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class PermissionsPolicyHeaderExtensions
/// The policy applied by <see cref="AddPermissionsPolicyWithDefaultSecureDirectives"/>
/// </summary>
internal const string DefaultSecurePolicy =
"accelerometer=(), ambient-light-sensor=(), autoplay=(), camera=(), display-capture=(), " +
"accelerometer=(), autoplay=(), camera=(), display-capture=(), " +
"encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), magnetometer=(), " +
"microphone=(), midi=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), " +
"screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()";
Expand Down Expand Up @@ -41,7 +41,7 @@ public static HeaderPolicyCollection AddPermissionsPolicy(this HeaderPolicyColle
/// not available by default, or not implemented. For consistency with <see cref="PermissionsPolicyBuilder"/>,
/// those directives are not included in the policy.
///
/// The policy added is equivalent to <c>accelerometer=(), ambient-light-sensor=(),
/// The policy added is equivalent to <c>accelerometer=(),
/// autoplay=(), camera=(), display-capture=(), encrypted-media=(), fullscreen=(),
/// geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(),
/// picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(),
Expand Down
Loading