Sha256: 2c05d8561c5500366ccadbac389550f5531b446acb86bd5a13667434af461793

Contents?: true

Size: 834 Bytes

Versions: 13

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true

require 'rack/protection'

module Rack
  module Protection
    ##
    # Prevented attack::   Secret leakage, third party tracking
    # Supported browsers:: mixed support
    # More infos::         https://www.w3.org/TR/referrer-policy/
    #                      https://caniuse.com/#search=referrer-policy
    #
    # Sets Referrer-Policy header to tell the browser to limit the Referer header.
    #
    # Options:
    # referrer_policy:: The policy to use (default: 'strict-origin-when-cross-origin')
    class ReferrerPolicy < Base
      default_options referrer_policy: 'strict-origin-when-cross-origin'

      def call(env)
        status, headers, body = @app.call(env)
        headers['Referrer-Policy'] ||= options[:referrer_policy]
        [status, headers, body]
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
rack-protection-3.2.0 lib/rack/protection/referrer_policy.rb
rack-protection-3.1.0 lib/rack/protection/referrer_policy.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.5/lib/rack/protection/referrer_policy.rb
rack-protection-3.0.6 lib/rack/protection/referrer_policy.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.5/lib/rack/protection/referrer_policy.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.5/lib/rack/protection/referrer_policy.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.5/lib/rack/protection/referrer_policy.rb
rack-protection-3.0.5 lib/rack/protection/referrer_policy.rb
rack-protection-3.0.4 lib/rack/protection/referrer_policy.rb
rack-protection-3.0.3 lib/rack/protection/referrer_policy.rb
rack-protection-3.0.2 lib/rack/protection/referrer_policy.rb
rack-protection-3.0.1 lib/rack/protection/referrer_policy.rb
rack-protection-3.0.0 lib/rack/protection/referrer_policy.rb