Make AD check for access work properly

parent adee3091
...@@ -36,9 +36,8 @@ module Gitlab ...@@ -36,9 +36,8 @@ module Gitlab
def allowed? def allowed?
if Gitlab::LDAP::Person.find_by_dn(user.extern_uid, adapter) if Gitlab::LDAP::Person.find_by_dn(user.extern_uid, adapter)
if ldap_config.active_directory return true unless ldap_config.active_directory
!Gitlab::LDAP::Person.disabled_via_active_directory?(user.extern_uid, adapter) !Gitlab::LDAP::Person.disabled_via_active_directory?(user.extern_uid, adapter)
end
else else
false false
end end
......
...@@ -60,6 +60,10 @@ module Gitlab ...@@ -60,6 +60,10 @@ module Gitlab
options['admin_group'] options['admin_group']
end end
def active_directory
options['active_directory']
end
protected protected
def base_config def base_config
Gitlab.config.ldap Gitlab.config.ldap
......
...@@ -28,19 +28,13 @@ describe Gitlab::LDAP::Access do ...@@ -28,19 +28,13 @@ describe Gitlab::LDAP::Access do
it { should be_true } it { should be_true }
end end
context 'and has no disabled flag in active diretory' do context 'withoud ActiveDirectory enabled' do
before { before do
Gitlab::LDAP::Person.stub(disabled_via_active_directory?: false) Gitlab::LDAP::Config.stub(enabled?: true)
Gitlab.config.ldap['enabled'] = true Gitlab::LDAP::Config.any_instance.stub(active_directory: false)
Gitlab.config.ldap['active_directory'] = false end
}
after {
Gitlab.config.ldap['enabled'] = false
Gitlab.config.ldap['active_directory'] = true
}
it { should be_false } it { should be_true }
end end
end end
end end
......
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