Sha256: f40f86fb1954f614fe1413529604a227359b7de4d285b895c8edc300ffcc7bca

Contents?: true

Size: 686 Bytes

Versions: 3

Compression:

Stored size: 686 Bytes

Contents

# frozen_string_literal: true

module ActionController #:nodoc:
  module ContentSecurityPolicy
    # TODO: Documentation
    extend ActiveSupport::Concern

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

      def content_security_policy_report_only(report_only = true, **options)
        before_action(options) do
          request.content_security_policy_report_only = report_only
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
actionpack-5.2.0.rc1 lib/action_controller/metal/content_security_policy.rb
actionpack-5.2.0.beta2 lib/action_controller/metal/content_security_policy.rb
actionpack-5.2.0.beta1 lib/action_controller/metal/content_security_policy.rb