Class: ClientAuthentication
- Inherits:
-
Object
- Object
- ClientAuthentication
show all
- Defined in:
- lib/client_authentication.rb
Defined Under Namespace
Classes: ClientAuthenticationException
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(headers, max_seconds = 5, model = Application, logger = nil) ⇒ ClientAuthentication
model must respond to :key and :secret
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/client_authentication.rb', line 5
def initialize(, max_seconds = 5, model = Application, logger=nil)
@headers =
@max_seconds = max_seconds
@model = model
@logger = logger
@header_keys = {
time: "X-Level3-Digest-Time",
key: "X-Level3-Application-Key",
digest: "X-Level3-Digest",
}
end
|
Instance Attribute Details
Returns the value of attribute header_keys.
2
3
4
|
# File 'lib/client_authentication.rb', line 2
def
@header_keys
end
|
Instance Method Details
#authenticate_client! ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'lib/client_authentication.rb', line 18
def authenticate_client!
key = @headers[ [:key] ]
time = @headers[ [:time] ]
digest = @headers[ [:digest] ]
(key, digest, time)
key
end
|
#generate_digest(salt, secret) ⇒ Object
41
42
43
44
45
46
|
# File 'lib/client_authentication.rb', line 41
def generate_digest(salt, secret)
Base64.encode64(
OpenSSL::HMAC.digest(
'sha256',secret, salt) ).
strip
end
|
#salt ⇒ Object
48
49
50
|
# File 'lib/client_authentication.rb', line 48
def salt
Time.now.to_i.to_s
end
|