Class: KeycloakOauth::Connection

Inherits:
Object
  • Object
show all
Includes:
Endpoints
Defined in:
lib/keycloak_oauth/connection.rb

Constant Summary

Constants included from Endpoints

Endpoints::DEFAULT_RESPONSE_TYPE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Endpoints

#authentication_endpoint, #authorization_endpoint, #logout_endpoint, #put_execute_actions_email_endpoint, #user_info_endpoint, #users_endpoint

Constructor Details

#initialize(auth_url:, realm:, client_id:, client_secret:, callback_module: nil) ⇒ Connection

Returns a new instance of Connection.



9
10
11
12
13
14
15
# File 'lib/keycloak_oauth/connection.rb', line 9

def initialize(auth_url:, realm:, client_id:, client_secret:, callback_module: nil)
  @auth_url = auth_url
  @realm = realm
  @client_id = client_id
  @client_secret = client_secret
  @callback_module = callback_module
end

Instance Attribute Details

#auth_urlObject (readonly)

Returns the value of attribute auth_url.



7
8
9
# File 'lib/keycloak_oauth/connection.rb', line 7

def auth_url
  @auth_url
end

#callback_moduleObject (readonly)

Returns the value of attribute callback_module.



7
8
9
# File 'lib/keycloak_oauth/connection.rb', line 7

def callback_module
  @callback_module
end

#client_idObject (readonly)

Returns the value of attribute client_id.



7
8
9
# File 'lib/keycloak_oauth/connection.rb', line 7

def client_id
  @client_id
end

#client_secretObject (readonly)

Returns the value of attribute client_secret.



7
8
9
# File 'lib/keycloak_oauth/connection.rb', line 7

def client_secret
  @client_secret
end

#realmObject (readonly)

Returns the value of attribute realm.



7
8
9
# File 'lib/keycloak_oauth/connection.rb', line 7

def realm
  @realm
end

Instance Method Details

#get_user_information(access_token:, refresh_token:) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/keycloak_oauth/connection.rb', line 17

def get_user_information(access_token:, refresh_token:)
  service = KeycloakOauth::UserInfoRetrievalService.new(
    access_token: access_token,
    refresh_token: refresh_token
  )
  service.perform
  service.parsed_response_body
end

#logout(session:) ⇒ Object



26
27
28
29
# File 'lib/keycloak_oauth/connection.rb', line 26

def logout(session:)
  service = KeycloakOauth::LogoutService.new(session)
  service.perform
end