123456789_123456789_123456789_123456789_123456789_

Class: Rack::Protection::ReferrerPolicy

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base
Instance Chain:
self, Base
Inherits: Rack::Protection::Base
Defined in: rack-protection/lib/rack/protection/referrer_policy.rb

Overview

Prevented attack

Secret leakage, third party tracking

Supported browsers

Most modern browsers from 2018 onwards. See https://caniuse.com/#search=referrer-policy for specifics.

More info

Sets the Referrer-Policy header to tell the browser to limit the Referer header.

Options

[:referrer_policy] The policy to use as a String. Default is 'strict-origin-when-cross-origin' (which, despite being the browser's default, is still set explicitly when this middleware is used). Note that this option has no effect if an upstream middleware (or your app) has set the Referrer-Policy header.

Constant Summary

Base - Inherited

DEFAULT_OPTIONS

Class Method Summary

Base - Inherited

.default_options

Used by subclasses to declare default values for options they require.

.default_reaction

Used by subclasses to declare default reaction when a request is rejected.

.new

Instance Attribute Summary

Base - Inherited

Instance Method Summary

Base - Inherited

#accepts?, #call, #debug, #default_options,
#default_reaction

Alias for Base#deny.

#deny

Deny the request.

#drop_session, #encrypt, #html?, #instrument, #origin, #random_string, #react, #referrer,
#report

When used as a reaction (with option reaction: :report), any rejected request will be allowed through, and a warning is omitted (note that warnings will not be shown if the :logging option has been set to false).

#safe?, #secure_compare, #session, #session?, #warn

Constructor Details

This class inherits a constructor from Rack::Protection::Base

Instance Method Details

#call(env)

[ GitHub ]

  
# File 'rack-protection/lib/rack/protection/referrer_policy.rb', line 26

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