class OmniAuth::Strategies::Nusso
Constants
- ATTRIBUTE_MAP
Public Instance Methods
connection()
click to toggle source
# File lib/omniauth/strategies/nusso.rb, line 30 def connection @connection ||= Faraday::Connection.new(options.base_url) end
Protected Instance Methods
callback_phase()
click to toggle source
Calls superclass method
# File lib/omniauth/strategies/nusso.rb, line 41 def callback_phase token = request.cookies[options.sso_cookie] response = get('validateWebSSOToken', webssotoken: token) @user_info = { 'uid' => response['netid'] } if options.include_attributes @user_info.merge!(get_directory_attributes(token, response['netid'])) end super rescue AuthException => err fail!(err.message) end
request_phase()
click to toggle source
# File lib/omniauth/strategies/nusso.rb, line 36 def request_phase response = get('get-ldap-redirect-url', goto: callback_url) redirect response['redirecturl'] end
Private Instance Methods
get(path, headers)
click to toggle source
# File lib/omniauth/strategies/nusso.rb, line 67 def get(path, headers) headers = headers.merge(apikey: options.consumer_key) response = connection.get(path, nil, headers) case response.status when 200..299 JSON.parse(response.body) when 407 raise AuthException, "Missing or Invalid Token" else raise AuthException, "Unknown Response" end end
get_directory_attributes(token, net_id)
click to toggle source
# File lib/omniauth/strategies/nusso.rb, line 89 def get_directory_attributes(token, net_id) response = get("validate-with-directory-search-response", webssotoken: token) Hash[ response['results'].first.map do |k, v| case v when [] then nil when "" then nil when Array then [k, v.first] else [k, v] end end.compact ] rescue AuthException, JSON::ParserError netid_user(net_id) end
netid_user(net_id)
click to toggle source
# File lib/omniauth/strategies/nusso.rb, line 80 def netid_user(net_id) { 'displayName' => net_id, 'givenName' => net_id, 'sn' => '(NetID)', 'mail' => "#{net_id}@#{options.netid_email_domain}" } end