Class: Gitlab::Auth::Ldap::Authentication
Instance Attribute Summary
#provider, #user
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize
Class Method Details
.login(login, password) ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/gitlab/auth/ldap/authentication.rb', line 13
def self.login(login, password)
return unless Gitlab::Auth::Ldap::Config.enabled?
return unless login.present? && password.present?
providers.find do |provider|
auth = new(provider)
break auth.user if auth.login(login, password) end
end
|
Instance Method Details
#adapter ⇒ Object
39
40
41
|
# File 'lib/gitlab/auth/ldap/authentication.rb', line 39
def adapter
OmniAuth::LDAP::Adaptor.new(config.omniauth_options)
end
|
#config ⇒ Object
43
44
45
|
# File 'lib/gitlab/auth/ldap/authentication.rb', line 43
def config
Gitlab::Auth::Ldap::Config.new(provider)
end
|
#login(login, password) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/gitlab/auth/ldap/authentication.rb', line 28
def login(login, password)
result = adapter.bind_as(
filter: user_filter(login),
size: 1,
password: password
)
return unless result
@user = Gitlab::Auth::Ldap::User.find_by_uid_and_provider(result.dn, provider)
end
|
#user_filter(login) ⇒ Object
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/gitlab/auth/ldap/authentication.rb', line 47
def user_filter(login)
filter = Net::LDAP::Filter.equals(config.uid, login)
if config.user_filter.present?
filter = Net::LDAP::Filter.join(filter, config.constructed_user_filter)
end
filter
end
|