Class: ActionDispatch::PermissionsPolicy
- Defined in:
- actionpack/lib/action_dispatch/http/permissions_policy.rb
Overview
Configures the HTTP Feature-Policy response header to specify which browser features the current document and its iframes can use.
Example global policy:
Rails.application.config. do |policy|
policy.camera :none
policy.gyroscope :none
policy.microphone :none
policy.usb :none
policy.fullscreen :self
policy.payment :self, "https://secure.example.com"
end
Defined Under Namespace
Modules: Request Classes: Middleware
Instance Attribute Summary collapse
-
#directives ⇒ Object
readonly
Returns the value of attribute directives.
Instance Method Summary collapse
- #build(context = nil) ⇒ Object
-
#initialize {|_self| ... } ⇒ PermissionsPolicy
constructor
A new instance of PermissionsPolicy.
- #initialize_copy(other) ⇒ Object
Constructor Details
#initialize {|_self| ... } ⇒ PermissionsPolicy
Returns a new instance of PermissionsPolicy.
117 118 119 120 |
# File 'actionpack/lib/action_dispatch/http/permissions_policy.rb', line 117 def initialize @directives = {} yield self if block_given? end |
Instance Attribute Details
#directives ⇒ Object (readonly)
Returns the value of attribute directives
115 116 117 |
# File 'actionpack/lib/action_dispatch/http/permissions_policy.rb', line 115 def directives @directives end |
Instance Method Details
#build(context = nil) ⇒ Object
155 156 157 |
# File 'actionpack/lib/action_dispatch/http/permissions_policy.rb', line 155 def build(context = nil) build_directives(context).compact.join("; ") end |
#initialize_copy(other) ⇒ Object
122 123 124 |
# File 'actionpack/lib/action_dispatch/http/permissions_policy.rb', line 122 def initialize_copy(other) @directives = other.directives.deep_dup end |