Flowdock
method

content_security_policy

Importance_2
v7.1.3.2 - Show latest stable - 0 notes - Class: ClassMethods
content_security_policy(enabled = true, **options, &block) public

Overrides parts of the globally configured Content-Security-Policy header:

class PostsController < ApplicationController
  content_security_policy do |policy|
    policy.base_uri "https://www.example.com"
  end
end

Options can be passed similar to before_action. For example, pass only: :index to override the header on the index action only:

class PostsController < ApplicationController
  content_security_policy(only: :index) do |policy|
    policy.default_src :self, :https
  end
end

Pass false to remove the Content-Security-Policy header:

class PostsController < ApplicationController
  content_security_policy false, only: :index
end
Show source
Register or log in to add new notes.