Class: OmniAuth::Strategies::DelegatedAuthentication

Inherits:
Object
  • Object
show all
Includes:
OmniAuth::Strategy
Defined in:
lib/omniauth/strategies/omniauth-delegated-authentication.rb

Defined Under Namespace

Classes: CallbackError

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

Returns the value of attribute consent_token.



12
13
14
# File 'lib/omniauth/strategies/omniauth-delegated-authentication.rb', line 12

def consent_token
  @consent_token
end

Instance Method Details

#callback_phaseObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/omniauth/strategies/omniauth-delegated-authentication.rb', line 29

def callback_phase
  if request.params['action'] == "cancel"
    raise CallbackError.new(request.params['action'], request.params['ResponseCode'])
  end

  self.consent_token = process_consent_token
  self.consent_token = client.refreshConsentToken(self.consent_token) unless consent_token.isValid?

  super
rescue CallbackError => e
  fail!(:invalid_credentials, e)
end

#callback_urlObject



20
21
22
# File 'lib/omniauth/strategies/omniauth-delegated-authentication.rb', line 20

def callback_url
  full_host + script_name + callback_path
end

#clientObject

AFIK there is no DelegatedAuthentication gem currently available, so this developer strategy assumes that this class will be overwritten by the provider strategy



16
17
18
# File 'lib/omniauth/strategies/omniauth-delegated-authentication.rb', line 16

def client
  ::DelegatedAuthentication.new(options[:app_id], options[:app_secret], nil, nil, options[:privacy_url], callback_url)
end

#request_phaseObject

Assumes that the provider strategy client method includes ‘getConsentUrl`



25
26
27
# File 'lib/omniauth/strategies/omniauth-delegated-authentication.rb', line 25

def request_phase
  redirect client.getConsentUrl(options[:scope], nil, callback_url, nil)
end