Class: OmniAuth::Strategies::Elitmus

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/elitmus.rb

Constant Summary collapse

DEFAULT_SCOPE =

class NoAuthorizationCodeError < StandardError; en

'public'

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



40
41
42
43
44
45
46
47
# File 'lib/omniauth/strategies/elitmus.rb', line 40

def authorize_params
  super.tap do |params|
    %w[scope auth_type disable_external_sso].each do |v|
      params[v.to_sym] = request.params[v] if request.params[v]
    end
    params[:scope] ||= DEFAULT_SCOPE
  end
end

#callback_urlObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/omniauth/strategies/elitmus.rb', line 49

def callback_url
  # NOTE: intentionally NOT calling `super` here. OmniAuth's default
  # callback_url is `full_host + callback_path + query_string`, where
  # query_string is whatever happens to be on the CURRENT request. That
  # makes redirect_uri drift between the /authorize request (which may
  # carry extra params like disable_external_sso) and the token-exchange
  # request (which additionally has code/state on it) - and OAuth2
  # requires both to match exactly, so any drift breaks the exchange.
  options[:callback_url] || (full_host + callback_path)
end

#prune!(hash) ⇒ Object



60
61
62
63
64
65
# File 'lib/omniauth/strategies/elitmus.rb', line 60

def prune!(hash)
  hash.delete_if do |_, value|
    prune!(value) if value.is_a?(Hash)
    value.nil? || (value.respond_to?(:empty?) && value.empty?)
  end
end

#raw_infoObject



36
37
38
# File 'lib/omniauth/strategies/elitmus.rb', line 36

def raw_info
  @raw_info ||= access_token.get('/api/v1/me').parsed
end