method

permissions_policy

Importance_2
v8.1.1 - Show latest stable - 0 notes - Class: ClassMethods
permissions_policy(**options, &block) public

Overrides parts of the globally configured `Feature-Policy` header:

class PagesController < ApplicationController
  permissions_policy do |policy|
    policy.geolocation "https://example.com"
  end
end

Options can be passed similar to `before_action`. For example, pass `only: :index` to override the header on the index action only:

class PagesController < ApplicationController
  permissions_policy(only: :index) do |policy|
    policy.camera :self
  end
end

Requires a global policy defined in an initializer, which can be empty:

Rails.application.config.permissions_policy do |policy|
  # policy.gyroscope :none
end
Show source
Register or log in to add new notes.