Class: KeycloakOauth::AuthorizableService

Inherits:
Object
  • Object
show all
Defined in:
app/services/keycloak_oauth/authorizable_service.rb

Constant Summary collapse

HTTP_SUCCESS_CODES =
[Net::HTTPOK, Net::HTTPNoContent, Net::HTTPCreated]
CONTENT_TYPE_X_WWW_FORM_URLENCODED =
'application/x-www-form-urlencoded'.freeze
CONTENT_TYPE_JSON =
'application/json'.freeze
AUTHORIZATION_HEADER =
'Authorization'.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#http_responseObject (readonly)

Returns the value of attribute http_response.



13
14
15
# File 'app/services/keycloak_oauth/authorizable_service.rb', line 13

def http_response
  @http_response
end

#parsed_response_bodyObject (readonly)

Returns the value of attribute parsed_response_body.



13
14
15
# File 'app/services/keycloak_oauth/authorizable_service.rb', line 13

def parsed_response_body
  @parsed_response_body
end

Class Method Details

.uri_with_supported_query_params(url, supported_params, given_params) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/services/keycloak_oauth/authorizable_service.rb', line 20

def self.uri_with_supported_query_params(url, supported_params, given_params)
  uri = URI.parse(url)

  query_params = supported_params.inject({}) do |acc, query_param|
    acc[query_param] = given_params[query_param] if given_params[query_param].present?
    acc
  end

  log_unsupported_params(given_params.keys - supported_params)

  uri.query = URI.encode_www_form(query_params) if query_params.values.any?
  uri
end

Instance Method Details

#performObject



15
16
17
18
# File 'app/services/keycloak_oauth/authorizable_service.rb', line 15

def perform
  @http_response = send_request
  @parsed_response_body ||= parse_response_body(http_response)
end