Sha256: 7cc8613ef6ef5e354e6d555e917c265e092abaf6e0eec765f1b994af25ecac81

Contents?: true

Size: 1.31 KB

Versions: 14

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module ActionController # :nodoc:
  # HTTP Permissions Policy is a web standard for defining a mechanism to
  # allow and deny the use of browser permissions in its own context, and
  # in content within any <iframe> elements in the document.
  #
  # Full details of HTTP Permissions Policy specification and guidelines can
  # be found at MDN:
  #
  # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy
  #
  # Examples of usage:
  #
  #   # Global policy
  #   Rails.application.config.permissions_policy do |f|
  #     f.camera      :none
  #     f.gyroscope   :none
  #     f.microphone  :none
  #     f.usb         :none
  #     f.fullscreen  :self
  #     f.payment     :self, "https://secure.example.com"
  #   end
  #
  #   # Controller level policy
  #   class PagesController < ApplicationController
  #     permissions_policy do |p|
  #       p.geolocation "https://example.com"
  #     end
  #   end
  module PermissionsPolicy
    extend ActiveSupport::Concern

    module ClassMethods
      def permissions_policy(**options, &block)
        before_action(options) do
          if block_given?
            policy = request.permissions_policy.clone
            yield policy
            request.permissions_policy = policy
          end
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/actionpack-7.0.2.3/lib/action_controller/metal/permissions_policy.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/actionpack-7.0.2.3/lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.2.4 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.2.3 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.2.2 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.2.1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.2 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.0 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.0.rc3 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.0.rc2 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.0.rc1 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.0.alpha2 lib/action_controller/metal/permissions_policy.rb
actionpack-7.0.0.alpha1 lib/action_controller/metal/permissions_policy.rb