Class: AuthenticationService

Inherits:
Object
  • Object
show all
Defined in:
lib/services/authentication_service.rb

Overview

Authentication Service for token activies

Class Method Summary collapse

Class Method Details

.create_authentication(auth_data) ⇒ Json

Creates authentication token

Parameters:

  • auth_data (object)

    Authentication object

Returns:

  • (Json)

    Response with brearer and refresh token



16
17
18
19
20
21
22
# File 'lib/services/authentication_service.rb', line 16

def self.create_authentication(auth_data)
  auth_payload = Authentication.get_payload_with_client_info(auth_data)
  RestClient::Request.execute(method: :post,
                              url: ApplicationConfig.get_url('create_authentication_path'),
                              payload: auth_payload,
                              headers: { 'Content-Type': 'application/json' })
end

.refresh_authentication_token(auth_data, bearer_token) ⇒ Json

Refresh authentication token

Parameters:

  • auth_data (Object)

    Authentication object

  • bearer_token (String)

Returns:

  • (Json)

    Response with brearer and refresh token



32
33
34
35
36
37
38
39
# File 'lib/services/authentication_service.rb', line 32

def self.refresh_authentication_token(auth_data, bearer_token)
  auth_payload = Authentication.get_payload_with_client_info(auth_data)
  RestClient::Request.execute(method: :post,
                              url: ApplicationConfig.get_url('create_authentication_path'),
                              payload: auth_payload,
                              headers: { 'Content-Type': 'application/json',
                                         'Authorization': bearer_token })
end

.revoke_authentication_token(auth_data, bearer_token) ⇒ Json

Revokes authentication token

Parameters:

  • auth_data (Object)

    Authentication object

  • bearer_token (String)

Returns:

  • (Json)

    Response with revoke message



49
50
51
52
53
54
55
56
# File 'lib/services/authentication_service.rb', line 49

def self.revoke_authentication_token(auth_data, bearer_token)
  auth_payload = Authentication.get_payload(auth_data)
  RestClient::Request.execute(method: :post,
                              url: ApplicationConfig.get_url('revoke_authentication_path'),
                              payload: auth_payload,
                              headers: { 'Content-Type': 'application/json',
                                         'Authorization': bearer_token })
end