Class: DuoUniversalRails::HealthCheckRequest
- Inherits:
-
Request
- Object
- Request
- DuoUniversalRails::HealthCheckRequest
show all
- Defined in:
- lib/duo_universal_rails/requests/health_check_request.rb
Instance Attribute Summary
Attributes inherited from Request
#client
Instance Method Summary
collapse
Methods inherited from Request
#default_headers, #get_request, #handle_response, #initialize, #post_request
Instance Method Details
#build_payload_params ⇒ Object
The time at which the JWT was created. key = iat, TYPE = Integer, REQUIRED = No
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/duo_universal_rails/requests/health_check_request.rb', line 39
def build_payload_params
{
iss: client.client_id,
sub: client.client_id,
aud: client.health_check_url,
exp: client.expire_in_sec,
jti: client.state,
iat: client.time_now_in_sec
}
end
|
#health_check_params ⇒ Object
10
11
12
13
14
15
|
# File 'lib/duo_universal_rails/requests/health_check_request.rb', line 10
def health_check_params
{
client_id: client.client_id,
client_assertion: jwt_client_assertion
}
end
|
#jwt_client_assertion ⇒ Object
50
51
52
|
# File 'lib/duo_universal_rails/requests/health_check_request.rb', line 50
def jwt_client_assertion
client.create_jwt_payload(payload: build_payload_params)
end
|
#parse_response(request) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/duo_universal_rails/requests/health_check_request.rb', line 55
def parse_response(request)
str_to_json = JSON.parse(request.body)
response = Object.new(str_to_json)
if response.stat == "OK"
{
status: true,
message: "Success"
}
elsif response.stat == "FAIL"
msg = "Status: Fail, code: #{response.code}, message: #{response.message}"
{
status: false,
message: msg
}
else
{
status: false,
message: "Someting went wrong!"
}
end
end
|
5
6
7
|
# File 'lib/duo_universal_rails/requests/health_check_request.rb', line 5
def ping
parse_response post_request([client.health_check_path].join(""), params: health_check_params)
end
|