File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -1201,6 +1201,43 @@ for allowing inline `<script>` tags.
1201
1201
This is used by the Rails UJS helper to create dynamically
1202
1202
loaded inline ` <script> ` elements.
1203
1203
1204
+ ### Feature-Policy Header
1205
+
1206
+ NOTE: The Feature-Policy header has been renamed to Permissions-Policy.
1207
+ The Permissions-Policy requires a different implementation and isn't
1208
+ yet supported by all browsers. To avoid having to rename this
1209
+ middleware in the future we use the new name for the middleware but
1210
+ keep the old header name and implementation for now.
1211
+
1212
+ To allow or block the use of browser features you can define a
1213
+ [ Feature-Policy] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy )
1214
+ response header for you application. Rails provides a DSL that allows you to
1215
+ configure the header.
1216
+
1217
+ Define the policy in the appropriate initializer:
1218
+
1219
+ ``` ruby
1220
+ # config/initializers/permissions_policy.rb
1221
+ Rails .application.config.permissions_policy do |policy |
1222
+ policy.camera :none
1223
+ policy.gyroscope :none
1224
+ policy.microphone :none
1225
+ policy.usb :none
1226
+ policy.fullscreen :self
1227
+ policy.payment :self , " https://secure.example.com"
1228
+ end
1229
+ ```
1230
+
1231
+ The globally configured policy can be overridden on a per-resource basis:
1232
+
1233
+ ``` ruby
1234
+ class PagesController < ApplicationController
1235
+ permissions_policy do |policy |
1236
+ policy.geolocation " https://example.com"
1237
+ end
1238
+ end
1239
+ ```
1240
+
1204
1241
Environmental Security
1205
1242
----------------------
1206
1243
You can’t perform that action at this time.
0 commit comments