mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-11 13:46:11 +10:00
Make AD check for access work properly
This commit is contained in:
@@ -36,9 +36,8 @@ module Gitlab
|
||||
|
||||
def allowed?
|
||||
if Gitlab::LDAP::Person.find_by_dn(user.extern_uid, adapter)
|
||||
if ldap_config.active_directory
|
||||
!Gitlab::LDAP::Person.disabled_via_active_directory?(user.extern_uid, adapter)
|
||||
end
|
||||
return true unless ldap_config.active_directory
|
||||
!Gitlab::LDAP::Person.disabled_via_active_directory?(user.extern_uid, adapter)
|
||||
else
|
||||
false
|
||||
end
|
||||
|
||||
@@ -60,6 +60,10 @@ module Gitlab
|
||||
options['admin_group']
|
||||
end
|
||||
|
||||
def active_directory
|
||||
options['active_directory']
|
||||
end
|
||||
|
||||
protected
|
||||
def base_config
|
||||
Gitlab.config.ldap
|
||||
|
||||
@@ -28,19 +28,13 @@ describe Gitlab::LDAP::Access do
|
||||
it { should be_true }
|
||||
end
|
||||
|
||||
context 'and has no disabled flag in active diretory' do
|
||||
before {
|
||||
Gitlab::LDAP::Person.stub(disabled_via_active_directory?: false)
|
||||
Gitlab.config.ldap['enabled'] = true
|
||||
Gitlab.config.ldap['active_directory'] = false
|
||||
}
|
||||
context 'withoud ActiveDirectory enabled' do
|
||||
before do
|
||||
Gitlab::LDAP::Config.stub(enabled?: true)
|
||||
Gitlab::LDAP::Config.any_instance.stub(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
|
||||
|
||||
Reference in New Issue
Block a user