Class: HonestRenter::SecretKeyMemberIdAuthenticator
Constant Summary
collapse
- ONE_HOUR =
3600
Instance Method Summary
collapse
from_address_and_password, from_secret_key_member_id, #initialize, #renew!, #session
Instance Method Details
#after_initialize(secret_key, member_id) ⇒ Object
32
33
34
35
|
# File 'lib/authenticator.rb', line 32
def after_initialize(secret_key, member_id)
@secret_key = secret_key
@member_id = member_id
end
|
#build_session ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/authenticator.rb', line 37
def build_session
json_hash = JSON(raw_hash)
digest = OpenSSL::Digest.new('sha256')
encoded = OpenSSL::HMAC.hexdigest(digest, @secret_key, json_hash)
HonestRenter::Session.new(encoded, json_hash)
end
|
#raw_hash ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/authenticator.rb', line 45
def raw_hash
now = Time.now
{
apiKey: ENV['HONEST_RENTER_API_KEY'],
authorization: 'member',
expires: now.to_i + ONE_HOUR,
person: @member_id,
renewableUntil: now.to_i + (3 * ONE_HOUR)
}
end
|