Class: Keycloak::Admin::Agent
- Inherits:
-
Object
- Object
- Keycloak::Admin::Agent
- Includes:
- HTTParty
- Defined in:
- lib/keycloak/admin/agent.rb
Overview
:nodoc: all
Instance Attribute Summary collapse
-
#always_terminate ⇒ Object
Returns the value of attribute always_terminate.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#grant_type ⇒ Object
Returns the value of attribute grant_type.
-
#password ⇒ Object
Returns the value of attribute password.
-
#realm ⇒ Object
Returns the value of attribute realm.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize ⇒ Agent
constructor
A new instance of Agent.
- #logout ⇒ Object
- #request(method, path, params: {}) ⇒ Object
Constructor Details
#initialize ⇒ Agent
Returns a new instance of Agent.
17 18 19 20 21 22 23 24 |
# File 'lib/keycloak/admin/agent.rb', line 17 def initialize @base_url = 'http://localhost:8080' @realm = 'master' @username = 'nil' @password = 'nil' @grant_type = 'password' @always_terminate = false end |
Instance Attribute Details
#always_terminate ⇒ Object
Returns the value of attribute always_terminate.
15 16 17 |
# File 'lib/keycloak/admin/agent.rb', line 15 def always_terminate @always_terminate end |
#base_url ⇒ Object
Returns the value of attribute base_url.
15 16 17 |
# File 'lib/keycloak/admin/agent.rb', line 15 def base_url @base_url end |
#grant_type ⇒ Object
Returns the value of attribute grant_type.
15 16 17 |
# File 'lib/keycloak/admin/agent.rb', line 15 def grant_type @grant_type end |
#password ⇒ Object
Returns the value of attribute password.
15 16 17 |
# File 'lib/keycloak/admin/agent.rb', line 15 def password @password end |
#realm ⇒ Object
Returns the value of attribute realm.
15 16 17 |
# File 'lib/keycloak/admin/agent.rb', line 15 def realm @realm end |
#username ⇒ Object
Returns the value of attribute username.
15 16 17 |
# File 'lib/keycloak/admin/agent.rb', line 15 def username @username end |
Instance Method Details
#logout ⇒ Object
26 27 28 |
# File 'lib/keycloak/admin/agent.rb', line 26 def logout terminate_session end |
#request(method, path, params: {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/keycloak/admin/agent.rb', line 36 def request(method, path, params: {}) refresh_session || create_session params[:headers] ||= {} params[:headers][:Authorization] = "Bearer #{@session['access_token']}" response = self.class.send( method, "#{@base_url}/#{path}", body: params[:body], headers: params[:headers] ) terminate_session if @always_terminate Keycloak::Admin.raise_error(response) if !response.code.between?(200, 299) response.parsed_response end |