]>
Commit | Line | Data |
---|---|---|
d586dfdf MG |
1 | package Apache2_4::AuthzCaps; |
2 | ||
3 | use 5.014000; | |
4 | use strict; | |
5 | use warnings; | |
6 | ||
7 | our $VERSION = '0.001001'; | |
8 | ||
9 | use Apache2::AuthzCaps 'hascaps'; | |
10 | use Apache2::Const qw/AUTHZ_GRANTED AUTHZ_DENIED AUTHZ_DENIED_NO_USER/; | |
11 | use Apache2::RequestRec; | |
12 | use Apache2::RequestUtil; | |
13 | ||
14 | ################################################## | |
15 | ||
16 | # General handler template stolen from Apache2_4::AuthCookie | |
17 | sub handler { | |
18 | my ($r, $caps) = @_; | |
19 | my $user = $r->user; | |
20 | local $Apache2::AuthzCaps::rootdir = $r->dir_config('AuthzCapsRootdir'); | |
21 | return AUTHZ_DENIED_NO_USER unless $user; | |
22 | my @caps = split ' ', $caps; | |
23 | hascaps($user, @caps) ? AUTHZ_GRANTED : AUTHZ_DENIED | |
24 | } | |
25 | ||
26 | 1; | |
27 | __END__ | |
28 | ||
29 | =encoding utf-8 | |
30 | ||
31 | =head1 NAME | |
32 | ||
33 | Apache2_4::AuthzCaps - mod_perl2 capability authorization for Apache 2.4 | |
34 | ||
35 | =head1 SYNOPSIS | |
36 | ||
37 | # In Apache2 config | |
38 | PerlAddAuthzProvider cap Apache2_4::AuthzCaps | |
39 | <Location /protected> | |
40 | # Insert authentication here | |
41 | PerlSetVar AuthzCapsRootdir /path/to/user/directory | |
42 | Require cap staff important | |
43 | Require cap admin | |
44 | </Location> | |
45 | # This will: | |
46 | # 1) Let important staff members access /protected | |
47 | # 2) Let admins access /protected | |
48 | # 3) Not let anyone else (such as an important non-staff member or an non-important staff member) access /protected | |
49 | ||
50 | =head1 DESCRIPTION | |
51 | ||
52 | Apache2_4::AuthzCaps is a modification of L<Apache2::AuthzCaps> for | |
53 | Apache 2.4. See that module's documentation for helper functions and | |
54 | more information. | |
55 | ||
56 | =head1 AUTHOR | |
57 | ||
58 | Marius Gavrilescu, E<lt>marius@ieval.roE<gt> | |
59 | ||
60 | =head1 COPYRIGHT AND LICENSE | |
61 | ||
62 | Copyright (C) 2013-2015 by Marius Gavrilescu | |
63 | ||
64 | This library is free software; you can redistribute it and/or modify | |
65 | it under the same terms as Perl itself, either Perl version 5.14.2 or, | |
66 | at your option, any later version of Perl 5 you may have available. |