Class: Rack::Padlock

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/padlock.rb,
lib/rack/padlock/server.rb,
lib/rack/padlock/version.rb,
lib/rack/padlock/selenium.rb,
lib/rack/padlock/phantomjs.rb,
lib/rack/padlock/string_util.rb

Defined Under Namespace

Classes: PadlockFile, Phantomjs, Selenium, Server, StringUtil, Webrick

Constant Summary collapse

POST_BODY =
'rack.input'.freeze
VERSION =
"0.0.3"
@@application =
nil
@@padlock_uris =
nil
@@debug =
false
@@logfile =
"tmp/padlock.log"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Padlock

Returns a new instance of Padlock.



10
11
12
# File 'lib/rack/padlock.rb', line 10

def initialize(app)
  @app = app
end

Class Method Details

.applicationObject



26
27
28
# File 'lib/rack/padlock.rb', line 26

def self.application
  @@application
end

.application=(app) ⇒ Object



22
23
24
# File 'lib/rack/padlock.rb', line 22

def self.application=(app)
  @@application = app
end

.debug=(flag) ⇒ Object



38
39
40
# File 'lib/rack/padlock.rb', line 38

def self.debug=(flag)
  @@debug = flag
end

.debug?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/rack/padlock.rb', line 42

def self.debug?
  @@debug
end

.logfileObject



50
51
52
# File 'lib/rack/padlock.rb', line 50

def self.logfile
  @@logfile
end

.logfile=(log) ⇒ Object



46
47
48
# File 'lib/rack/padlock.rb', line 46

def self.logfile=(log)
  @@logfile = log
end

.padlock_uris(base_uri) ⇒ Object



34
35
36
# File 'lib/rack/padlock.rb', line 34

def self.padlock_uris(base_uri)
  @@padlock_uris.map {|path| "#{base_uri}#{path}" } if @@padlock_uris
end

.padlock_uris=(uri_list) ⇒ Object



30
31
32
# File 'lib/rack/padlock.rb', line 30

def self.padlock_uris=(uri_list)
  @@padlock_uris = uri_list
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/rack/padlock.rb', line 14

def call(env)
  return poke_response if poke?(env)
  return capture_violation(env) if csp_policy_violation?(env)
  status, headers, body = @app.call(env)
  headers.merge!(csp_headers(env))
  [status, headers, body]
end