From 211f4e60ebc94a7fd73564ca750f7f52f416773f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 29 Apr 2019 15:11:43 +0200 Subject: [PATCH] =?utf8?q?LDAP-Auth:=20Konfiguration=20=C3=BCber=20Konstru?= =?utf8?q?ktur=20=C3=BCbergeben?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Ist eine Vorarbeit dafür, das LDAP-Modul mit unterschiedlichen Konfigurationen benutzen zu können. --- SL/Auth.pm | 3 +-- SL/Auth/LDAP.pm | 17 +++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) 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.')); -- 2.20.1