Sha256: 30bc702e808a04cc45a857f3dc06d7bc18251d7913aff390926d62c4e11b08c2

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'content-security-policy/middleware'
require 'content-security-policy/errors'
require 'content-security-policy/version'

class ContentSecurityPolicy
  class << self

    # @attr_accessor [Boolean] use in report only mode
    attr_accessor :report_only
    # @attr_reader [Hash] directives hash
    attr_reader :directives

    #
    # Configures Content Security Policy directives.
    #
    # Note that default-src directive should always be set.
    #
    # @example
    #   ContentSecurityPolicy.configure do |csp|
    #     csp.report_only = true
    #     csp['default-src'] = "'self'"
    #     csp['script-src']  = '*.example.com'
    #   end
    #   use ContentSecurityPolicy
    #
    # @yield [self]
    #
    def configure(&blk)
      @directives ||= {}
      blk.call(self)
    end

    #
    # Sets directive.
    #
    # @param [String] name Directive name
    # @param [String] value Directive value
    #
    def []=(name, value)
      @directives[name] = value
    end

  end # << self
end # ContentSecurityPolicy

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
content-security-policy-0.1.1 lib/content-security-policy.rb