From: Moritz Bunkus Date: Mon, 29 Apr 2019 13:11:43 +0000 (+0200) Subject: LDAP-Auth: Konfiguration über Konstruktur übergeben X-Git-Tag: release-3.5.6.1~512 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=211f4e60ebc94a7fd73564ca750f7f52f416773f;p=kivitendo-erp.git LDAP-Auth: Konfiguration über Konstruktur übergeben Ist eine Vorarbeit dafür, das LDAP-Modul mit unterschiedlichen Konfigurationen benutzen zu können. --- diff --git a/SL/Auth.pm b/SL/Auth.pm index 9f52a37e1..74a7d7fe5 100644 --- a/SL/Auth.pm +++ b/SL/Auth.pm @@ -140,14 +140,13 @@ sub _read_auth_config { } else { $self->{DB_config} = $::lx_office_conf{'authentication/database'}; - $self->{LDAP_config} = $::lx_office_conf{'authentication/ldap'}; } if ($self->{module} eq 'DB') { $self->{authenticator} = SL::Auth::DB->new($self); } elsif ($self->{module} eq 'LDAP') { - $self->{authenticator} = SL::Auth::LDAP->new($self); + $self->{authenticator} = SL::Auth::LDAP->new($::lx_office_conf{'authentication/ldap'}); } if (!$self->{authenticator}) { diff --git a/SL/Auth/LDAP.pm b/SL/Auth/LDAP.pm index 8311c7015..b42bf8702 100644 --- a/SL/Auth/LDAP.pm +++ b/SL/Auth/LDAP.pm @@ -2,7 +2,6 @@ package SL::Auth::LDAP; use English '-no_match_vars'; -use Scalar::Util qw(weaken); use SL::Auth::Constants qw(:all); use strict; @@ -12,11 +11,9 @@ sub new { die 'The module "Net::LDAP" is not installed.'; } - my $type = shift; - my $self = {}; - - $self->{auth} = shift; - weaken $self->{auth}; + my $type = shift; + my $self = {}; + $self->{config} = shift; bless $self, $type; @@ -31,7 +28,7 @@ sub reset { sub _connect { my $self = shift; - my $cfg = $self->{auth}->{LDAP_config}; + my $cfg = $self->{config}; return $self->{ldap} if $self->{ldap}; @@ -65,7 +62,7 @@ sub _get_filter { my ($cfg, $filter); - $cfg = $self->{auth}->{LDAP_config}; + $cfg = $self->{config}; $filter = "$cfg->{filter}"; $filter =~ s|^\s+||; @@ -104,7 +101,7 @@ sub _get_user_dn { return $self->{dn_cache}->{$login} if $self->{dn_cache}->{$login}; - my $cfg = $self->{auth}->{LDAP_config}; + my $cfg = $self->{config}; my $filter = $self->_get_filter($login); @@ -160,7 +157,7 @@ sub verify_config { my $locale = $main::locale; my $self = shift; - my $cfg = $self->{auth}->{LDAP_config}; + my $cfg = $self->{config}; if (!$cfg) { $form->error($locale->text('config/kivitendo.conf: Key "authentication/ldap" is missing.'));