Class: G5AuthenticatableApi::Services::TokenInfo

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

Overview

Extract access token from request to retrieve token data from G5 Auth

Direct Known Subclasses

TokenValidator, UserFetcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}, headers = {}, warden = nil) ⇒ TokenInfo

Returns a new instance of TokenInfo.



9
10
11
12
13
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 9

def initialize(params = {}, headers = {}, warden = nil)
  @params = params || {}
  @headers = headers || {}
  @warden = warden
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



7
8
9
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 7

def headers
  @headers
end

#paramsObject (readonly)

Returns the value of attribute params.



7
8
9
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 7

def params
  @params
end

#wardenObject (readonly)

Returns the value of attribute warden.



7
8
9
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 7

def warden
  @warden
end

Instance Method Details

#access_tokenObject



15
16
17
18
19
20
21
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 15

def access_token
  @access_token ||= begin
                      extract_token_from_header ||
                        extract_token_from_params ||
                        extract_token_from_warden
                    end
end

#auth_clientObject



27
28
29
30
31
32
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 27

def auth_client
  @auth_client ||= G5AuthenticationClient::Client.new(
    allow_password_credentials: 'false',
    access_token: access_token
  )
end

#token_dataObject



23
24
25
# File 'lib/g5_authenticatable_api/services/token_info.rb', line 23

def token_data
  auth_client.token_info
end