Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5d23fb60

Von Sven Schöling vor fast 15 Jahren hinzugefügt

  • ID 5d23fb605bc40f699ab677e6ee13a7e498c9fb14
  • Vorgänger 63e0f606
  • Nachfolger 251480b5

Auth Konstanten ausgelagert in ein eigenes Package.

Dadurch keine Probleme mit zirkulären Includes mehr. Ausserdem DBI an der richtigen Stelle eingebunden.

Unterschiede anzeigen:

SL/Auth.pm
package SL::Auth;
use constant OK => 0;
use constant ERR_PASSWORD => 1;
use constant ERR_BACKEND => 100;
use constant SESSION_OK => 0;
use constant SESSION_NONE => 1;
use constant SESSION_EXPIRED => 2;
use DBI;
use Digest::MD5 qw(md5_hex);
use IO::File;
use Time::HiRes qw(gettimeofday);
use List::MoreUtils qw(uniq);
use SL::Auth::Constants qw(:all);
use SL::Auth::DB;
use SL::Auth::LDAP;
SL/Auth/Constants.pm
package SL::Auth::Constants;
use strict;
use Exporter qw(import);
our %EXPORT_TAGS = (
OK => [ qw(
OK
) ],
ERR => [ qw(
ERR_PASSWORD
ERR_BACKEND
) ],
SESSION => [ qw(
SESSION_OK
SESSION_NONE
SESSION_EXPIRED
) ],
);
# add all the other ":class" tags to the ":all" class,
# deleting duplicates
{
my %seen;
push @{$EXPORT_TAGS{all}}, grep {!$seen{$_}++} @$_ for values %EXPORT_TAGS;
}
Exporter::export_ok_tags('all');
use constant OK => 0;
use constant ERR_PASSWORD => 1;
use constant ERR_BACKEND => 100;
use constant SESSION_OK => 0;
use constant SESSION_NONE => 1;
use constant SESSION_EXPIRED => 2;
1;
__END__
=head1 NAME
SL::Auth::Constants - COnstants for Auth module
=head1 SYNOPSIS
use SL::Auth::Constants qw(:all);
OK == $auth->authenticate($user, $pass) or die;
=head1 DESCRIPTION
This module provides status constants for authentication handling
=head1 FUNCTIONS
=head1 BUGS
=head1 AUTHOR
=cut
SL/Auth/DB.pm
package SL::Auth::DB;
use DBI;
#use SL::Auth;
use SL::Auth::Constants qw(:all);
use SL::DBUtils;
use strict;
......
if (!$dbh) {
$main::lxdebug->leave_sub();
return SL::Auth->ERR_BACKEND();
return ERR_BACKEND;
}
my $query = qq|SELECT password FROM auth."user" WHERE login = ?|;
......
$main::lxdebug->leave_sub();
return $password eq $stored_password ? SL::Auth->OK() : SL::Auth->ERR_PASSWORD();
return $password eq $stored_password ? OK : ERR_PASSWORD;
}
sub can_change_password {
......
if (!$dbh) {
$main::lxdebug->leave_sub();
return SL::Auth->ERR_BACKEND()
return ERR_BACKEND;
}
$password = crypt $password, substr($login, 0, 2) if (!$is_crypted);
SL/Auth/LDAP.pm
use English '-no_match_vars';
#use SL::Auth;
use SL::Auth::Constants qw(:all);
use strict;
......
if ($is_crypted) {
$main::lxdebug->leave_sub();
return SL::Auth->ERR_BACKEND();
return ERR_BACKEND;
}
my $ldap = $self->_connect();
if (!$ldap) {
$main::lxdebug->leave_sub();
return SL::Auth->ERR_BACKEND();
return ERR_BACKEND;
}
my $dn = $self->_get_user_dn($ldap, $login);
......
if (!$dn) {
$main::lxdebug->leave_sub();
return SL::Auth->ERR_BACKEND();
return ERR_BACKEND;
}
my $mesg = $ldap->bind($dn, 'password' => $password);
......
$main::lxdebug->leave_sub();
return $mesg->is_error() ? SL::Auth->ERR_PASSWORD() : SL::Auth->OK();
return $mesg->is_error() ? ERR_PASSWORD : OK;
}
sub can_change_password {
......
}
sub change_password {
return SL::Auth->ERR_BACKEND();
return ERR_BACKEND;
}
sub verify_config {

Auch abrufbar als: Unified diff