Commit e10b9447 authored by Imre Farkas's avatar Imre Farkas

Merge branch 'dblessing_ldap_admin_mode_fix' into 'master'

Fix admin mode when authenticating with LDAP

See merge request gitlab-org/gitlab!64823
parents 81857f90 a8717235
......@@ -1234,7 +1234,7 @@ class User < ApplicationRecord
end
def matches_identity?(provider, extern_uid)
identities.where(provider: provider, extern_uid: extern_uid).exists?
identities.with_extern_uid(provider, extern_uid).exists?
end
def project_deploy_keys
......
......@@ -2813,6 +2813,14 @@ RSpec.describe User do
end
end
describe '#matches_identity?' do
it 'finds the identity when the DN is formatted differently' do
user = create(:omniauth_user, provider: 'ldapmain', extern_uid: 'uid=john smith,ou=people,dc=example,dc=com')
expect(user.matches_identity?('ldapmain', 'uid=John Smith, ou=People, dc=example, dc=com')).to eq(true)
end
end
describe '#ldap_block' do
let(:user) { create(:omniauth_user, provider: 'ldapmain', name: 'John Smith') }
......
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