2015-09-08 05:58:48 -04:00
|
|
|
# Class to parse and transform the info provided by omniauth
|
|
|
|
#
|
|
|
|
module Gitlab
|
|
|
|
module LDAP
|
|
|
|
class AuthHash < Gitlab::OAuth::AuthHash
|
|
|
|
private
|
|
|
|
|
|
|
|
def get_info(key)
|
2015-09-23 10:37:59 -04:00
|
|
|
attributes = ldap_config.attributes[key.to_s]
|
2015-09-16 03:14:04 -04:00
|
|
|
return super unless attributes
|
2015-09-08 05:58:48 -04:00
|
|
|
|
2015-09-16 03:14:04 -04:00
|
|
|
attributes = Array(attributes)
|
|
|
|
|
|
|
|
value = nil
|
|
|
|
attributes.each do |attribute|
|
|
|
|
value = get_raw(attribute)
|
2015-09-23 10:37:59 -04:00
|
|
|
value = value.first if value
|
2015-09-16 03:14:04 -04:00
|
|
|
break if value.present?
|
|
|
|
end
|
2015-09-08 05:58:48 -04:00
|
|
|
|
|
|
|
return super unless value
|
|
|
|
|
|
|
|
Gitlab::Utils.force_utf8(value)
|
|
|
|
value
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_raw(key)
|
|
|
|
auth_hash.extra[:raw_info][key]
|
|
|
|
end
|
2015-09-09 06:40:31 -04:00
|
|
|
|
|
|
|
def ldap_config
|
|
|
|
@ldap_config ||= Gitlab::LDAP::Config.new(self.provider)
|
|
|
|
end
|
2015-09-08 05:58:48 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|