Module: EY::GateKeeper::Responses
- Defined in:
- lib/ey_gatekeeper/responses.rb
Constant Summary collapse
- CANNED_RESPONSES =
The canned responses
{ :unable_to_create_token => 'unable to create token', :invalid_authentication => 'invalid authentication info', :no_authentication => 'no authentication info', :no_token => 'no token specified', :invalid_token => 'invalid token specified', :expired_token => 'expired token specified', :token_insufficient => 'token has insufficient access', :invalid_impersonation_token => 'invalid impersonation token specified', :expired_impersonation_token => 'expired impersonation token specified', :impersonation_token_insufficient => 'impersonation token has insufficient access' }.freeze
Class Method Summary collapse
-
.possible_responses ⇒ Object
A list of possible response symbols.
-
.string(lookup = nil) ⇒ Object
Get the response string via symbol.
Instance Method Summary collapse
-
#token_response(token) ⇒ Array
Standard token response The response body is a json encoded hash and contains the token (keyed as ‘token’) and it’s expiration (keyed as ‘expires’).
-
#unauthorized_response(message) ⇒ Array
Standard Unauthorized rsponse.
Class Method Details
.possible_responses ⇒ Object
A list of possible response symbols
25 26 27 |
# File 'lib/ey_gatekeeper/responses.rb', line 25 def self.possible_responses CANNED_RESPONSES.keys end |
.string(lookup = nil) ⇒ Object
Get the response string via symbol
20 21 22 |
# File 'lib/ey_gatekeeper/responses.rb', line 20 def self.string(lookup = nil) CANNED_RESPONSES.fetch(lookup,'') end |
Instance Method Details
#token_response(token) ⇒ Array
Standard token response The response body is a json encoded hash and contains the token (keyed as ‘token’) and it’s expiration (keyed as ‘expires’)
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ey_gatekeeper/responses.rb', line 51 def token_response(token) response = { 'token' => token['uri'].split("/")[2], 'expires' => token['expires'] }.to_json [ 200, { 'Content-Type' => 'application/json', 'Content-Length' => response.length.to_s, }, [response] ] end |
#unauthorized_response(message) ⇒ Array
Standard Unauthorized rsponse. Just add message
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ey_gatekeeper/responses.rb', line 34 def () [ 401, { 'Content-Type' => 'text/plain', 'Content-Length' => '0', 'X-Gatekeeper-Authentication-Error' => .is_a?(Symbol) ? EY::GateKeeper::Responses.string() : .to_s }, [] ] end |