Module: ActionDispatch::ContentSecurityPolicy::Request

Included in:
Request
Defined in:
lib/action_dispatch/http/content_security_policy.rb

Constant Summary collapse

POLICY =
"action_dispatch.content_security_policy"
POLICY_REPORT_ONLY =
"action_dispatch.content_security_policy_report_only"
NONCE_GENERATOR =
"action_dispatch.content_security_policy_nonce_generator"
NONCE =
"action_dispatch.content_security_policy_nonce"
NONCE_DIRECTIVES =
"action_dispatch.content_security_policy_nonce_directives"

Instance Method Summary collapse

Instance Method Details

#content_security_policyObject



53
54
55
# File 'lib/action_dispatch/http/content_security_policy.rb', line 53

def content_security_policy
  get_header(POLICY)
end

#content_security_policy=(policy) ⇒ Object



57
58
59
# File 'lib/action_dispatch/http/content_security_policy.rb', line 57

def content_security_policy=(policy)
  set_header(POLICY, policy)
end

#content_security_policy_nonceObject



85
86
87
88
89
90
91
92
93
# File 'lib/action_dispatch/http/content_security_policy.rb', line 85

def content_security_policy_nonce
  if content_security_policy_nonce_generator
    if nonce = get_header(NONCE)
      nonce
    else
      set_header(NONCE, generate_content_security_policy_nonce)
    end
  end
end

#content_security_policy_nonce_directivesObject



77
78
79
# File 'lib/action_dispatch/http/content_security_policy.rb', line 77

def content_security_policy_nonce_directives
  get_header(NONCE_DIRECTIVES)
end

#content_security_policy_nonce_directives=(generator) ⇒ Object



81
82
83
# File 'lib/action_dispatch/http/content_security_policy.rb', line 81

def content_security_policy_nonce_directives=(generator)
  set_header(NONCE_DIRECTIVES, generator)
end

#content_security_policy_nonce_generatorObject



69
70
71
# File 'lib/action_dispatch/http/content_security_policy.rb', line 69

def content_security_policy_nonce_generator
  get_header(NONCE_GENERATOR)
end

#content_security_policy_nonce_generator=(generator) ⇒ Object



73
74
75
# File 'lib/action_dispatch/http/content_security_policy.rb', line 73

def content_security_policy_nonce_generator=(generator)
  set_header(NONCE_GENERATOR, generator)
end

#content_security_policy_report_onlyObject



61
62
63
# File 'lib/action_dispatch/http/content_security_policy.rb', line 61

def content_security_policy_report_only
  get_header(POLICY_REPORT_ONLY)
end

#content_security_policy_report_only=(value) ⇒ Object



65
66
67
# File 'lib/action_dispatch/http/content_security_policy.rb', line 65

def content_security_policy_report_only=(value)
  set_header(POLICY_REPORT_ONLY, value)
end