Add Kerberos and NTLM authentication support

Fixes #41
This commit is contained in:
Lars Kanis 2023-02-03 19:45:30 +01:00
parent 20fd3118ed
commit 10d0f39694
2 changed files with 32 additions and 2 deletions

View File

@ -5,13 +5,25 @@
# Connection parameters to LDAP server # Connection parameters to LDAP server
# see also: http://net-ldap.rubyforge.org/Net/LDAP.html#method-c-new # see also: http://net-ldap.rubyforge.org/Net/LDAP.html#method-c-new
ldap_connection: ldap_connection:
host: localhost host: ldapserver
port: 389 port: 389
auth: auth:
method: :simple method: :simple
username: CN=username,OU=!Serviceaccounts,OU=company,DC=company,DC=de username: CN=username,OU=!Serviceaccounts,OU=company,DC=company,DC=de
password: secret password: secret
# or GSSAPI / Kerberos authentication:
auth:
method: :gssapi
hostname: ldapserver
# or GSS-SPNEGO / NTLM authentication
auth:
method: :gss_spnego
domain: 'company.de'
username: 'myuser'
password: 'secret'
# Search parameters for LDAP users which should be synchronized # Search parameters for LDAP users which should be synchronized
ldap_users: ldap_users:
base: OU=company,OU=company,DC=company,DC=de base: OU=company,OU=company,DC=company,DC=de

View File

@ -361,8 +361,26 @@ class Application
def start! def start!
read_config_file(@config_fname) read_config_file(@config_fname)
ldap_conf = @config[:ldap_connection]
auth_meth = ldap_conf.dig(:auth, :method).to_s
if auth_meth == "gssapi"
begin
require 'net/ldap/auth_adapter/gssapi'
rescue LoadError => err
raise "#{err}\nTo use GSSAPI authentication please run:\n gem install net-ldap-auth_adapter-gssapi"
end
elsif auth_meth == "gss_spnego"
begin
require 'net-ldap-gss-spnego'
# This doesn't work since this file is defined in net-ldap as a placeholder:
# require 'net/ldap/auth_adapter/gss_spnego'
rescue LoadError => err
raise "#{err}\nTo use GSSAPI authentication please run:\n gem install net-ldap-gss-spnego"
end
end
# gather LDAP users and groups # gather LDAP users and groups
@ldap = Net::LDAP.new @config[:ldap_connection] @ldap = Net::LDAP.new ldap_conf
ldap_users = uniq_names search_ldap_users ldap_users = uniq_names search_ldap_users
ldap_groups = uniq_names search_ldap_groups ldap_groups = uniq_names search_ldap_groups