Use provider based ldap config

parent 63132b75
......@@ -42,17 +42,17 @@ module Gitlab
end
def update_permissions(user)
if Gitlab.config.ldap['sync_ssh_keys']
if ldap_config['sync_ssh_keys']
update_ssh_keys(user)
end
# Skip updating group permissions
# if instance does not use group_base setting
return true unless Gitlab.config.ldap['group_base'].present?
return true unless ldap_config['group_base'].present?
update_ldap_group_links(user)
if Gitlab.config.ldap['admin_group'].present?
if ldap_config['admin_group'].present?
update_admin_status(user)
end
end
......@@ -71,7 +71,7 @@ module Gitlab
(ldap_user.ssh_keys - user.keys.ldap.pluck(:key)).each do |key|
Rails.logger.info "#{self.class.name}: adding LDAP SSH key #{key.inspect} to #{user.name} (#{user.id})"
new_key = LDAPKey.new(title: "LDAP - #{Gitlab.config.ldap['sync_ssh_keys']}", key: key)
new_key = LDAPKey.new(title: "LDAP - #{ldap_config['sync_ssh_keys']}", key: key)
new_key.user = user
unless new_key.save
Rails.logger.error "#{self.class.name}: failed to add LDAP SSH key #{key.inspect} to #{user.name} (#{user.id})\n"\
......@@ -100,7 +100,7 @@ module Gitlab
end
def update_admin_status(user)
admin_group = Gitlab::LDAP::Group.find_by_cn(Gitlab.config.ldap['admin_group'], adapter)
admin_group = Gitlab::LDAP::Group.find_by_cn(ldap_config['admin_group'], adapter)
if admin_group.has_member?(Gitlab::LDAP::Person.find_by_dn(user.extern_uid, adapter))
unless user.admin?
user.admin = true
......@@ -140,6 +140,10 @@ module Gitlab
end.map(&:cn)
end
def ldap_config
Gitlab::LDAP::Adapter.config_for(provider)
end
private
def gitlab_groups_with_ldap_link
::Group.includes(:ldap_group_links).references(:ldap_group_links).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment