Sha256: 25fd8726b7b84330e70ee11fc87d1b439fdf82cc74b08197df664edafb42c17e
Contents?: true
Size: 679 Bytes
Versions: 3
Compression:
Stored size: 679 Bytes
Contents
require 'http-cookie' module SoarAuthenticationToken class CookieProvider def initialize(configuration) @configuration = configuration validate_configuration end def fetch(request) return false unless request.env.has_key?('HTTP_COOKIE') cookies = HTTP::CookieJar.new.parse(request.env['HTTP_COOKIE'], 'http://irrelevant') auth_cookie = cookies.find { |cookie| cookie.name == @configuration['cookie_name'] } return false unless auth_cookie.is_a?(HTTP::Cookie) auth_cookie.value end def validate_configuration raise "'cookie_name' must be configured" unless @configuration['cookie_name'] end end end
Version data entries
3 entries across 3 versions & 1 rubygems