Class: OmniAuth::Strategies::NCU

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

Constant Summary collapse

DEFAULT_SCOPES =
%w(user.info.basic.read)

Instance Method Summary collapse

Instance Method Details

#authorize_paramsObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/omniauth/strategies/ncu.rb', line 26

def authorize_params
  super.tap do |params|
    %w[scope client_options].each do |v|
      if request.params[v]
        params[v.to_sym] = request.params[v]
      end
    end
    params[:scope] = params[:scope].join ' ' if params[:scope]
  end
end

#info_allowed?Boolean



71
72
73
74
75
# File 'lib/omniauth/strategies/ncu.rb', line 71

def info_allowed?
  info_scopes = %w(user.info.basic.read)
  scope = (options['scope'] || DEFAULT_SCOPES)
  (info_scopes & scope).any?
end

#raw_infoObject



62
63
64
65
66
67
68
69
# File 'lib/omniauth/strategies/ncu.rb', line 62

def raw_info
  return {} unless info_allowed?
  access_token.options[:mode] = :header
  @raw_info ||= access_token.get('personnel/v1/info').parsed
rescue ::OAuth2::Error => e
  Logger.new(STDOUT).info e.to_s
  {}
end

#request_phaseObject



22
23
24
# File 'lib/omniauth/strategies/ncu.rb', line 22

def request_phase
  super
end