| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PlugAuth::Lite; |
|
2
|
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
949822
|
use strict; |
|
|
6
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
189
|
|
|
4
|
6
|
|
|
6
|
|
38
|
use warnings; |
|
|
6
|
|
|
|
|
19
|
|
|
|
6
|
|
|
|
|
171
|
|
|
5
|
6
|
|
|
6
|
|
124
|
use 5.010001; |
|
|
6
|
|
|
|
|
25
|
|
|
6
|
6
|
|
|
6
|
|
34
|
use Mojo::Base qw( Mojolicious ); |
|
|
6
|
|
|
|
|
15
|
|
|
|
6
|
|
|
|
|
49
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: Pluggable (lite) authentication and authorization server. |
|
9
|
|
|
|
|
|
|
our $VERSION = '0.36_01'; # TRIAL VERSION |
|
10
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'auth'; |
|
14
|
|
|
|
|
|
|
has 'authz'; |
|
15
|
|
|
|
|
|
|
has 'host'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub startup |
|
18
|
|
|
|
|
|
|
{ |
|
19
|
5
|
|
|
5
|
1
|
24898
|
my($self, $config) = @_; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$self->plugin('plug_auth_lite', |
|
22
|
0
|
|
|
0
|
|
0
|
auth => $self->auth // sub { 0 }, |
|
23
|
1
|
|
|
1
|
|
9
|
authz => $self->authz // sub { 1 }, |
|
24
|
2
|
|
|
2
|
|
24
|
host => $self->host // sub { 0 }, |
|
25
|
5
|
|
100
|
|
|
31
|
); |
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=pod |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=encoding UTF-8 |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
PlugAuth::Lite - Pluggable (lite) authentication and authorization server. |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 VERSION |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
version 0.36_01 |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
command line: |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
% plugauthlite |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Mojolicious Plugin: |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
use Mojolicious::Lite; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
plugin 'plug_auth_lite', |
|
55
|
|
|
|
|
|
|
auth => sub { |
|
56
|
|
|
|
|
|
|
my($user, $pass) = @_; |
|
57
|
|
|
|
|
|
|
if($user eq 'optimus' && $pass eq 'matrix') |
|
58
|
|
|
|
|
|
|
{ return 1; } |
|
59
|
|
|
|
|
|
|
else |
|
60
|
|
|
|
|
|
|
{ return 0; } |
|
61
|
|
|
|
|
|
|
}, |
|
62
|
|
|
|
|
|
|
authz => sub { |
|
63
|
|
|
|
|
|
|
my($user, $action, $resource) = @_; |
|
64
|
|
|
|
|
|
|
if($user eq 'optimus && $action eq 'open' && $resource =~ m{^/matrix}) |
|
65
|
|
|
|
|
|
|
{ return 1 } |
|
66
|
|
|
|
|
|
|
else |
|
67
|
|
|
|
|
|
|
{ return 0 } |
|
68
|
|
|
|
|
|
|
}; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Mojolicious App: |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
use PlugAuth::Lite; |
|
73
|
|
|
|
|
|
|
my $app = PlugAuth::Lite->new({ |
|
74
|
|
|
|
|
|
|
auth => sub { |
|
75
|
|
|
|
|
|
|
my($user, $pass) = @_; |
|
76
|
|
|
|
|
|
|
if($user eq 'optimus' && $pass eq 'matrix') |
|
77
|
|
|
|
|
|
|
{ return 1; } |
|
78
|
|
|
|
|
|
|
else |
|
79
|
|
|
|
|
|
|
{ return 0; } |
|
80
|
|
|
|
|
|
|
}, |
|
81
|
|
|
|
|
|
|
authz => sub { |
|
82
|
|
|
|
|
|
|
my($user, $action, $resource) = @_; |
|
83
|
|
|
|
|
|
|
if($user eq 'optimus && $action eq 'open' && $resource =~ m{^/matrix}) |
|
84
|
|
|
|
|
|
|
{ return 1 } |
|
85
|
|
|
|
|
|
|
else |
|
86
|
|
|
|
|
|
|
{ return 0 } |
|
87
|
|
|
|
|
|
|
}, |
|
88
|
|
|
|
|
|
|
}); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This distribution provides |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over 4 |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item L<plugauthlite> |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
L<PlugAuth> compatible server in the form of a L<Mojolicious::Lite> application. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item L<Mojolicious::Plugin::PlugAuthLite> |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
L<Mojolicious> plugin that adds L<PlugAuth> compatible routes to a new or |
|
103
|
|
|
|
|
|
|
existing L<Mojolicious> application. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item L<PlugAuth::Lite> |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L<Mojolicious> application with L<PlugAuth> compatible routes that can be spawned |
|
108
|
|
|
|
|
|
|
from within a perl application. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=back |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
In the future it will also contain a testing interface for testing authentication |
|
113
|
|
|
|
|
|
|
and authorization rules in L<Clustericious> applications. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
It has fewer prerequisites that the full fledged L<PlugAuth> server (simply |
|
116
|
|
|
|
|
|
|
L<Mojolicious> and perl itself) but also fewer features (it notably lacks |
|
117
|
|
|
|
|
|
|
the management interface). |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 auth |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Subroutine reference to call to check authentication. Passes in C<($user, $pass)> should |
|
124
|
|
|
|
|
|
|
return true for authenticated, false otherwise. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
If not provided, all authentications fail. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 authz |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Subroutine reference to call to check authorization. Passes in C<($user, $action, $resource)> |
|
131
|
|
|
|
|
|
|
and should return true for authorized, false otherwise. |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
If not provided, all authorizations succeed. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 host |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Subroutine reference to call to check host information. |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L<plugauthlite>, |
|
142
|
|
|
|
|
|
|
L<Mojolicious::Plugin::PlugAuthLite>, |
|
143
|
|
|
|
|
|
|
L<Test::PlugAuth>, |
|
144
|
|
|
|
|
|
|
L<Clustericious> |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHOR |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Graham Ollis <plicease@cpan.org> |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Graham Ollis. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
155
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=cut |