line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Authen::Simple::RADIUS; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
869
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
15
|
use base 'Authen::Simple::Adapter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
963
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
71451
|
use Authen::Radius; |
|
1
|
|
|
|
|
86531
|
|
|
1
|
|
|
|
|
117
|
|
8
|
1
|
|
|
1
|
|
13
|
use Params::Validate qw[]; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
337
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = 0.1; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->options({ |
13
|
|
|
|
|
|
|
host => { |
14
|
|
|
|
|
|
|
type => Params::Validate::SCALAR, |
15
|
|
|
|
|
|
|
default => 'localhost', |
16
|
|
|
|
|
|
|
optional => 1 |
17
|
|
|
|
|
|
|
}, |
18
|
|
|
|
|
|
|
port => { |
19
|
|
|
|
|
|
|
type => Params::Validate::SCALAR, |
20
|
|
|
|
|
|
|
default => 1812, |
21
|
|
|
|
|
|
|
optional => 1 |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
timeout => { |
24
|
|
|
|
|
|
|
type => Params::Validate::SCALAR, |
25
|
|
|
|
|
|
|
default => 10, |
26
|
|
|
|
|
|
|
optional => 1 |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
secret => { |
29
|
|
|
|
|
|
|
type => Params::Validate::SCALAR, |
30
|
|
|
|
|
|
|
optional => 0 |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
}); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub check { |
35
|
0
|
|
|
0
|
1
|
|
my ( $self, $username, $password ) = @_; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $connection = Authen::Radius->new( |
38
|
|
|
|
|
|
|
Host => sprintf( "%s:%d", $self->host, $self->port ), |
39
|
|
|
|
|
|
|
Secret => $self->secret, |
40
|
|
|
|
|
|
|
Timeout => $self->timeout |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
unless ( defined $connection ) { |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $host = $self->host; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
$self->log->error( qq/Failed to connect to '$host'. Reason: '$@'/ ) |
48
|
|
|
|
|
|
|
if $self->log; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return 0; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
unless ( $connection->check_pwd( $username, $password ) ) { |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $error = $connection->strerror; |
56
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
|
|
|
$self->log->debug( qq/Failed to authenticate user '$username'. Reason: '$error'/ ) |
58
|
|
|
|
|
|
|
if $self->log; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return 0; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
$self->log->debug( qq/Successfully authenticated user '$username'./ ) |
64
|
|
|
|
|
|
|
if $self->log; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
return 1; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |