line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PlugAuth::Plugin::FlatUserList; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: PlugAuth plugin that provides a user list without authentication. |
4
|
|
|
|
|
|
|
our $VERSION = '0.38'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
1858
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
115
|
|
8
|
4
|
|
|
4
|
|
20
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
100
|
|
9
|
4
|
|
|
4
|
|
20
|
use Role::Tiny::With; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
172
|
|
10
|
4
|
|
|
4
|
|
21
|
use File::stat qw( stat ); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
33
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
with 'PlugAuth::Role::Plugin'; |
13
|
|
|
|
|
|
|
with 'PlugAuth::Role::Auth'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub init |
16
|
|
|
|
|
|
|
{ |
17
|
3
|
|
|
3
|
0
|
5
|
my($self) = @_; |
18
|
3
|
|
|
|
|
9
|
$self->{filename} = $self->plugin_config->user_list_file; |
19
|
3
|
|
|
|
|
133
|
$self->{mtime} = 0; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub check_credentials |
24
|
|
|
|
|
|
|
{ |
25
|
2
|
|
|
2
|
1
|
25
|
my($self, $user, $pass) = @_; |
26
|
2
|
|
|
|
|
12
|
return $self->deligate_check_credentials($user, $pass); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub all_users |
31
|
|
|
|
|
|
|
{ |
32
|
|
|
|
|
|
|
my($self) = @_; |
33
|
|
|
|
|
|
|
my $mtime = stat($self->{filename})->mtime; |
34
|
|
|
|
|
|
|
if($mtime != $self->{mtime}) |
35
|
|
|
|
|
|
|
{ |
36
|
|
|
|
|
|
|
open(my $fh, '<', $self->{filename}); |
37
|
|
|
|
|
|
|
my @list = grep !/^\s*$/, <$fh>; |
38
|
|
|
|
|
|
|
chomp @list; |
39
|
|
|
|
|
|
|
close $fh; |
40
|
|
|
|
|
|
|
$self->{mtime} = $mtime; |
41
|
|
|
|
|
|
|
$self->{list} = \@list; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
return @{ $self->{list} }; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=pod |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=encoding UTF-8 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 NAME |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
PlugAuth::Plugin::FlatUserList - PlugAuth plugin that provides a user list without authentication. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 VERSION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
version 0.38 |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SYNOPSIS |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
In your PlugAuth.conf file: |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
--- |
67
|
|
|
|
|
|
|
plugins: |
68
|
|
|
|
|
|
|
- PlugAuth::Plugin::FlatUserList: |
69
|
|
|
|
|
|
|
user_list_file: /path/to/user_list.txt |
70
|
|
|
|
|
|
|
- PlugAuth::Plugin::LDAP: {} |
71
|
|
|
|
|
|
|
ldap : |
72
|
|
|
|
|
|
|
server : ldap://1.2.3.4:389 |
73
|
|
|
|
|
|
|
dn : uid=%s, ou=people, dc=users, dc=example, dc=com |
74
|
|
|
|
|
|
|
authoritative : 1 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Then in /path/to/user_list.txt |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
alice |
79
|
|
|
|
|
|
|
bob |
80
|
|
|
|
|
|
|
george |
81
|
|
|
|
|
|
|
... |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DESCRIPTION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This plugin provides a user list, stored as a flat file. It just provides a user list, |
86
|
|
|
|
|
|
|
no authentication. All authentication requests are passed onto the next authentication |
87
|
|
|
|
|
|
|
plugin in your configuration. The intent of this plugin is to provide a user list for |
88
|
|
|
|
|
|
|
authentication plugins which do not otherwise provide a user list (The above example |
89
|
|
|
|
|
|
|
shows how to configure this plugin with the L<LDAP|PlugAuth::Plugin::LDAP> plugin as |
90
|
|
|
|
|
|
|
an example). |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
The format of the user list is a simple text file, one line per user. Do not use |
93
|
|
|
|
|
|
|
spaces, comments, tabs or anything like that as they are not supported. This plugin |
94
|
|
|
|
|
|
|
does NOT support modifying the user list through the PlugAuth RESTful API. You will |
95
|
|
|
|
|
|
|
need to hand edit the user list to add and remove users. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
L<PlugAuth> needs an accurate user list to compute the list of groups and to handle |
98
|
|
|
|
|
|
|
authorization, as there is a special group for each user that contains exactly just |
99
|
|
|
|
|
|
|
that user and has the same name as that user. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 METHODS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head2 $plugin-E<gt>check_credentials( $user, $pass ) |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Check if the username and password is a valid credentials. This plugin just passes |
106
|
|
|
|
|
|
|
the request on to the next authentication plugin without checking the username or |
107
|
|
|
|
|
|
|
password. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 $plugin-E<gt>all_users |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns the list of users in the user list file. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SEE ALSO |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L<PlugAuth> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 AUTHOR |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Graham Ollis <gollis@sesda3.com> |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This software is copyright (c) 2012 by NASA GSFC. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
126
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |