Sha256: 2d6b9917dd9e8c6e40e7346459d06d466c455e3e059ffebf7df3a9f76febb3cb

Contents?: true

Size: 1.31 KB

Versions: 36

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

36 entries across 36 versions & 4 rubygems

Version Path
actionpack-6.1.4.4 lib/action_controller/metal/permissions_policy.rb
actionpack-6.1.4.3 lib/action_controller/metal/permissions_policy.rb
actionpack-6.1.4.2 lib/action_controller/metal/permissions_policy.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/actionpack-6.1.4.1/lib/action_controller/metal/permissions_policy.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/actionpack-6.1.4.1/lib/action_controller/metal/permissions_policy.rb
actionpack-6.1.4.1 lib/action_controller/metal/permissions_policy.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/actionpack-6.1.4/lib/action_controller/metal/permissions_policy.rb
actionpack-6.1.4 lib/action_controller/metal/permissions_policy.rb
actionpack-6.1.3.2 lib/action_controller/metal/permissions_policy.rb
actionpack-6.1.3.1 lib/action_controller/metal/permissions_policy.rb
actionpack-6.1.3 lib/action_controller/metal/permissions_policy.rb
actionpack-6.1.2.1 lib/action_controller/metal/permissions_policy.rb
actionpack-6.1.2 lib/action_controller/metal/permissions_policy.rb
actionpack-6.1.1 lib/action_controller/metal/permissions_policy.rb
actionpack-6.1.0 lib/action_controller/metal/permissions_policy.rb
actionpack-6.1.0.rc2 lib/action_controller/metal/permissions_policy.rb