| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::Squid::Auth::Plugin::UserList; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23904
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
309
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Net::Squid::Auth::Plugin::UserList - A User List-Based Credentials Validation Plugin for L |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.02 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = 0.02; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
If you're a system administrator trying to use L to |
|
21
|
|
|
|
|
|
|
validate your user's credentials using a user:password list as credentials |
|
22
|
|
|
|
|
|
|
repository, do as described here: |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
On C<$Config{InstallScript}/squid-auth-engine>'s configuration file: |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
plugin = UserList |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
users = <
|
|
29
|
|
|
|
|
|
|
joe_average:secret |
|
30
|
|
|
|
|
|
|
john_manager:terces |
|
31
|
|
|
|
|
|
|
EOF |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
On your Squid HTTP Cache configuration: |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
auth_param basic /usr/bin/squid-auth-engine /etc/squid-auth-engine.conf |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
And you're ready to use this module. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
If you're a developer, you might be interested in reading through the source |
|
41
|
|
|
|
|
|
|
code of this module, in order to learn about it's internals and how it works. |
|
42
|
|
|
|
|
|
|
It may give you ideas about how to implement other plugin modules for |
|
43
|
|
|
|
|
|
|
L. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 new( $config_hash ) |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Constructor. Expects a hash reference with all the configuration under the |
|
50
|
|
|
|
|
|
|
section I<< >> in the C<$Config{InstallScript}/squid-auth-engine> as |
|
51
|
|
|
|
|
|
|
parameter. Returns a plugin instance. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub new { |
|
56
|
0
|
|
|
0
|
1
|
|
my ( $class, $config ) = @_; |
|
57
|
0
|
0
|
|
|
|
|
return unless UNIVERSAL::isa( $config, 'HASH' ); |
|
58
|
0
|
|
|
|
|
|
return bless { _config => $config }, $class; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 initialize() |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Initialization function. Gets a user list from the 'users' parameter in the |
|
64
|
|
|
|
|
|
|
configuration hash passed in to C and parses it using "\n" as user |
|
65
|
|
|
|
|
|
|
record split and ":" as user / password separator inside of every record. |
|
66
|
|
|
|
|
|
|
Returns nothing, as specified by the plugin interface. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub initialize { |
|
71
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
72
|
0
|
|
|
|
|
|
my @users = split "\n", $self->{_config}{users}; |
|
73
|
0
|
|
|
|
|
|
foreach my $record (@users) { |
|
74
|
0
|
|
|
|
|
|
my ( $username, $password ) = split ':', $record; |
|
75
|
0
|
|
|
|
|
|
$self->{_usermap}{$username} = $password; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
0
|
|
|
|
|
|
return; |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 is_valid( $username, $password ) |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This is the credential validation interface. It expects a username and password |
|
83
|
|
|
|
|
|
|
as parameters and returns a boolean indicating if the credentials are valid |
|
84
|
|
|
|
|
|
|
(i.e., are listed in the configuration file) or not. |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub is_valid { |
|
89
|
0
|
|
|
0
|
1
|
|
my ( $self, $username, $password ) = @_; |
|
90
|
0
|
0
|
|
|
|
|
return 0 unless exists $self->{_usermap}{$username}; |
|
91
|
1
|
|
|
1
|
|
6
|
no warnings; |
|
|
1
|
|
|
|
|
9
|
|
|
|
1
|
|
|
|
|
95
|
|
|
92
|
0
|
|
|
|
|
|
return $self->{_usermap}{$username} eq $password; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 OTHER IMPLEMENTATIONS |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 L |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
A simple LDAP-based credentials validation plugin for L. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Luis Motta Campos, C<< >> |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 BUGS |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
108
|
|
|
|
|
|
|
C, or through the web |
|
109
|
|
|
|
|
|
|
interface at |
|
110
|
|
|
|
|
|
|
L. |
|
111
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
112
|
|
|
|
|
|
|
your bug as I make changes. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SUPPORT |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
perldoc Net::Squid::Auth::Plugin::UserList |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
You can also look for information at: |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=over 4 |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * Search CPAN |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
L |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Copyright 2008 Luis Motta Campos, all rights reserved. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
149
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
1; # End of Net::Squid::Auth::Plugin::UserList |