Sha256: 17f3b243db841ee08f22f5e784aafd39e0845d0d6d9fb974aab63de2259307dd
Contents?: true
Size: 1.72 KB
Versions: 1
Compression:
Stored size: 1.72 KB
Contents
module ApiAuth module RequestDrivers # :nodoc: class ActionControllerRequest # :nodoc: include ApiAuth::Helpers def initialize(request) @request = request fetch_headers true end def set_auth_header(header) @request.env['Authorization'] = header fetch_headers @request end def calculated_md5 body = @request.raw_post md5_base64digest(body) end def populate_content_md5 if @request.put? || @request.post? @request.env['Content-MD5'] = calculated_md5 fetch_headers end end def md5_mismatch? if @request.put? || @request.post? calculated_md5 != content_md5 else false end end def fetch_headers @headers = capitalize_keys @request.env end def http_method @request.request_method.to_s.upcase end def content_type value = find_header(%w(CONTENT-TYPE CONTENT_TYPE HTTP_CONTENT_TYPE)) value.nil? ? '' : value end def content_md5 value = find_header(%w(CONTENT-MD5 CONTENT_MD5 HTTP_CONTENT_MD5)) value.nil? ? '' : value end def request_uri @request.request_uri end def set_date @request.env['HTTP_DATE'] = Time.now.utc.httpdate fetch_headers end def timestamp value = find_header(%w(DATE HTTP_DATE)) value.nil? ? '' : value end def authorization_header find_header %w(Authorization AUTHORIZATION HTTP_AUTHORIZATION) end private def find_header(keys) keys.map { |key| @headers[key] }.compact.first end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
api-auth-2.0.0 | lib/api_auth/request_drivers/action_controller.rb |