Module: Hawk::Client

Extended by:
Client
Included in:
Client
Defined in:
lib/hawk/client.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(authorization_header, options) ⇒ Object



7
8
9
# File 'lib/hawk/client.rb', line 7

def authenticate(authorization_header, options)
  Hawk::AuthorizationHeader.authenticate(authorization_header, { :server_response => true, :type => 'response' }.merge(options))
end

#build_authorization_header(options) ⇒ Object



11
12
13
# File 'lib/hawk/client.rb', line 11

def build_authorization_header(options)
  Hawk::AuthorizationHeader.build(options)
end

#calculate_time_offset(authorization_header, options) ⇒ Object



15
16
17
18
19
20
# File 'lib/hawk/client.rb', line 15

def calculate_time_offset(authorization_header, options)
  parts = AuthorizationHeader.parse(authorization_header)
  expected_mac = Crypto.ts_mac(:ts => parts[:ts], :credentials => options[:credentials])
  return unless expected_mac == parts[:tsm]
  parts[:ts].to_i - Time.now.to_i
end