lib/safe_cookies/configuration.rb in safe_cookies-0.1.5 vs lib/safe_cookies/configuration.rb in safe_cookies-0.1.6

- old
+ new

@@ -11,16 +11,17 @@ end end class Configuration - attr_reader :registered_cookies, :fix_cookie_paths, :correct_cookie_paths_timestamp + attr_reader :registered_cookies, :fix_cookie_paths, :correct_cookie_paths_timestamp, :ignored_cookies def initialize self.registered_cookies = {} self.insecure_cookies = [] self.scriptable_cookies = [] + self.ignored_cookies = [] end # Register cookies you expect to receive. The middleware will rewrite all # registered cookies it receives, making them both secure and http_only. # @@ -43,10 +44,18 @@ registered_cookies[name] = (options || {}).freeze insecure_cookies << name if options[:secure] == false scriptable_cookies << name if options[:http_only] == false end + # Ignore cookies that you don't control like this: + # + # ignore_cookie 'ignored_cookie' + # ignore_cookie /^__utm/ + def ignore_cookie(name_or_regex) + self.ignored_cookies << name_or_regex + end + def fix_paths(options = {}) options.has_key?(:for_cookies_secured_before) or raise MissingOptionError.new("Was told to fix paths without the :for_cookies_secured_before timestamp.") self.fix_cookie_paths = true self.correct_cookie_paths_timestamp = options[:for_cookies_secured_before] @@ -61,10 +70,10 @@ end private attr_accessor :insecure_cookies, :scriptable_cookies - attr_writer :registered_cookies, :fix_cookie_paths, :correct_cookie_paths_timestamp + attr_writer :registered_cookies, :fix_cookie_paths, :correct_cookie_paths_timestamp, :ignored_cookies end end \ No newline at end of file