Class: TrainPlugins::Rest::HmacSignature
Overview
Authentication via HMAC Signature.
Instance Attribute Summary
Attributes inherited from AuthHandler
#connection, #options
Instance Method Summary
collapse
Methods inherited from AuthHandler
#auth_headers, #auth_parameters, descendants, #initialize, #login, #logout, name, #process_error, #renew_session, #renewal_needed?
Instance Method Details
#check_options ⇒ Object
7
8
9
10
11
12
|
# File 'lib/train-rest/auth_handler/hmac-signature.rb', line 7
def check_options
raise ArgumentError.new("Need :hmac_secret for HMAC signatures") unless options[:hmac_secret]
options[:header] ||= "X-Signature"
options[:digest] ||= "SHA256"
end
|
#digest ⇒ Object
18
19
20
|
# File 'lib/train-rest/auth_handler/hmac-signature.rb', line 18
def digest
options[:digest]
end
|
22
23
24
|
# File 'lib/train-rest/auth_handler/hmac-signature.rb', line 22
def
options[:header]
end
|
#hmac_secret ⇒ Object
14
15
16
|
# File 'lib/train-rest/auth_handler/hmac-signature.rb', line 14
def hmac_secret
options[:hmac_secret]
end
|
#process(payload: "", headers: {}, url: "", method: nil) ⇒ Object
30
31
32
33
34
35
36
|
# File 'lib/train-rest/auth_handler/hmac-signature.rb', line 30
def process(payload: "", headers: {}, url: "", method: nil)
{
headers: {
=> OpenSSL::HMAC.hexdigest(digest, hmac_secret, payload)
}
}
end
|
#signature_based? ⇒ Boolean
26
27
28
|
# File 'lib/train-rest/auth_handler/hmac-signature.rb', line 26
def signature_based?
true
end
|