class Mixlib::Authentication::HTTPAuthenticationRequest
Constants
- MANDATORY_HEADERS
Attributes
request[R]
Public Class Methods
new(request)
click to toggle source
# File lib/mixlib/authentication/http_authentication_request.rb, line 29 def initialize(request) @request = request @request_signature = nil validate_headers! end
Public Instance Methods
content_hash()
click to toggle source
# File lib/mixlib/authentication/http_authentication_request.rb, line 63 def content_hash headers[:x_ops_content_hash].chomp end
headers()
click to toggle source
# File lib/mixlib/authentication/http_authentication_request.rb, line 35 def headers @headers ||= @request.env.inject({ }) { |memo, kv| memo[$2.gsub(/\-/,"_").downcase.to_sym] = kv[1] if kv[0] =~ /^(HTTP_)(.*)/; memo } end
host()
click to toggle source
# File lib/mixlib/authentication/http_authentication_request.rb, line 59 def host headers[:host].chomp end
http_method()
click to toggle source
# File lib/mixlib/authentication/http_authentication_request.rb, line 39 def http_method @request.method.to_s end
path()
click to toggle source
# File lib/mixlib/authentication/http_authentication_request.rb, line 43 def path @request.path.to_s end
request_signature()
click to toggle source
# File lib/mixlib/authentication/http_authentication_request.rb, line 67 def request_signature unless @request_signature @request_signature = headers.find_all { |h| h[0].to_s =~ /^x_ops_authorization_/ }.sort { |x,y| x.to_s <=> y.to_s}.map { |i| i[1] }.join("\n") Mixlib::Authentication::Log.debug "Reconstituted (user-supplied) request signature: #{@request_signature}" end @request_signature end
signing_description()
click to toggle source
# File lib/mixlib/authentication/http_authentication_request.rb, line 47 def signing_description headers[:x_ops_sign].chomp end
timestamp()
click to toggle source
# File lib/mixlib/authentication/http_authentication_request.rb, line 55 def timestamp headers[:x_ops_timestamp].chomp end
user_id()
click to toggle source
# File lib/mixlib/authentication/http_authentication_request.rb, line 51 def user_id headers[:x_ops_userid].chomp end
validate_headers!()
click to toggle source
# File lib/mixlib/authentication/http_authentication_request.rb, line 76 def validate_headers! missing_headers = MANDATORY_HEADERS - headers.keys unless missing_headers.empty? missing_headers.map! { |h| h.to_s.upcase } raise MissingAuthenticationHeader, "missing required authentication header(s) '#{missing_headers.join("', '")}'" end end