@@ -14,6 +14,7 @@ use Dancer::Plugin::Passphrase;
|
||||
use Digest::MD5;
|
||||
use Net::LDAP;
|
||||
use Authen::Radius;
|
||||
use Authen::TacacsPlus;
|
||||
use Try::Tiny;
|
||||
|
||||
sub authenticate_user {
|
||||
@@ -113,6 +114,9 @@ sub match_password {
|
||||
elsif ($user->radius) {
|
||||
$pwmatch_result = $self->match_with_radius($password, $username);
|
||||
}
|
||||
elsif ($user->tacacs) {
|
||||
$pwmatch_result = $self->match_with_tacacs($password, $username);
|
||||
}
|
||||
else {
|
||||
$pwmatch_result = $self->match_with_local_pass($password, $user);
|
||||
}
|
||||
@@ -251,4 +255,24 @@ sub match_with_radius {
|
||||
return $radius_return;
|
||||
}
|
||||
|
||||
sub match_with_tacacs {
|
||||
my($self, $pass, $user) = @_;
|
||||
return unless setting('tacacs') and ref {} eq ref setting('tacacs');
|
||||
|
||||
my $conf = setting('tacacs');
|
||||
my $tacacs = new Authen::TacacsPlus(Host => $conf->{server}, Key => $conf->{key});
|
||||
if (not $tacacs) {
|
||||
debug sprintf('auth error: Authen::TacacsPlus: %s', Authen::TacacsPlus::errmsg());
|
||||
return undef;
|
||||
}
|
||||
|
||||
my $tacacs_return = $tacacs->authen($user,$pass);
|
||||
if (not $tacacs_return) {
|
||||
debug sprintf('error: Authen::TacacsPlus: %s', Authen::TacacsPlus::errmsg());
|
||||
}
|
||||
$tacacs->close();
|
||||
|
||||
return $tacacs_return;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user