Class: Rack::BlacklistCookies
- Inherits:
-
Object
- Object
- Rack::BlacklistCookies
show all
- Defined in:
- lib/rack-blacklist_cookies.rb,
lib/rack/blacklist_cookies.rb,
lib/rack/blacklist_cookies/version.rb,
lib/rack/blacklist_cookies/scrubber.rb,
lib/rack/blacklist_cookies/configuration.rb
Overview
Rack::BlacklistCookies is a middleware that removes selected cookies from the request and / or response.
Defined Under Namespace
Classes: BaseScrubber, Configuration, ConfigurationError, RequestScrubber, ResponseScrubber
Constant Summary
collapse
- VERSION =
"1.0.0".freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of BlacklistCookies.
5
6
7
|
# File 'lib/rack/blacklist_cookies.rb', line 5
def initialize(app)
@app = app
end
|
Class Method Details
.configuration ⇒ Object
10
11
12
|
# File 'lib/rack-blacklist_cookies.rb', line 10
def self.configuration
@configuration ||= Configuration.new
end
|
14
15
16
17
18
19
20
|
# File 'lib/rack-blacklist_cookies.rb', line 14
def self.configure
yield(configuration)
configuration.validate
rescue ConfigurationError => error
configuration.reset
raise error
end
|
.request_blacklist(env) ⇒ Object
22
23
24
|
# File 'lib/rack-blacklist_cookies.rb', line 22
def self.request_blacklist(env)
configuration.request_blacklist[env["PATH_INFO"]]
end
|
.response_blacklist(env) ⇒ Object
26
27
28
|
# File 'lib/rack-blacklist_cookies.rb', line 26
def self.response_blacklist(env)
configuration.response_blacklist[env["PATH_INFO"]]
end
|
Instance Method Details
#call(env) ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/rack/blacklist_cookies.rb', line 9
def call(env)
env["HTTP_COOKIE"] = "#{RequestScrubber.new(env, env["HTTP_COOKIE"])}" if scrub_request?(env)
status, , body = @app.call(env)
["Set-Cookie"] = "#{ResponseScrubber.new(env, ["Set-Cookie"])}" if scrub_response?(env, )
[status, , body]
end
|