Class: DHC::Auth

Inherits:
Interceptor show all
Includes:
ActiveSupport::Configurable
Defined in:
lib/dhc/interceptors/auth.rb

Instance Attribute Summary

Attributes inherited from Interceptor

#request

Instance Method Summary collapse

Methods inherited from Interceptor

#after_request, #all_interceptor_classes, #before_response, dup, #initialize, #response

Constructor Details

This class inherits a constructor from DHC::Interceptor

Instance Method Details

#after_responseObject



17
18
19
20
# File 'lib/dhc/interceptors/auth.rb', line 17

def after_response
  reauthenticate! if configuration_correct? && reauthenticate?
  retry_with_refreshed_token! if retry_with_refreshed_token?
end

#before_initObject



7
8
9
10
# File 'lib/dhc/interceptors/auth.rb', line 7

def before_init
  body_authentication! if auth_options[:body]
  auth_options[:refresh].call if refresh_bearer?
end

#before_requestObject



12
13
14
15
# File 'lib/dhc/interceptors/auth.rb', line 12

def before_request
  bearer_authentication! if auth_options[:bearer]
  basic_authentication! if auth_options[:basic]
end