Class: G5AuthenticatableApi::Services::TokenValidator

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

Instance Attribute Summary collapse

Attributes inherited from TokenInfo

#headers, #params, #warden

Instance Method Summary collapse

Methods inherited from TokenInfo

#access_token, #auth_client, #initialize, #token_data

Constructor Details

This class inherits a constructor from G5AuthenticatableApi::Services::TokenInfo

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



6
7
8
# File 'lib/g5_authenticatable_api/services/token_validator.rb', line 6

def error
  @error
end

Instance Method Details

#auth_response_headerObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/g5_authenticatable_api/services/token_validator.rb', line 25

def auth_response_header
  if error
    auth_header = "Bearer"

    if access_token
      auth_header << " error=\"#{error_code}\""
      auth_header << ",error_description=\"#{error_description}\"" if error_description
    end

    auth_header
  end
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  begin
    validate!
    true
  rescue StandardError => e
    false
  end
end

#validate!Object



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

def validate!
  begin
    token_data unless skip_validation?
  rescue StandardError => @error
    raise error
  end
end