File Coverage

blib/lib/Apache/Authenlemonldap.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package Apache::Authenlemonldap;
2 1     1   53781 use Apache::Constants qw(:common);
  0            
  0            
3             use Apache2::Log;
4             our $VERSION = '1.0.0';
5             sub handler {
6             my $r = shift;
7             return OK unless $r->is_initial_req;
8             my ( $res, $role ) = $r->get_basic_auth_pw;
9             return $res if $res;
10             my $user = $r->connection->user;
11             if ( !$user ) {
12             $r->note_basic_auth_failure;
13             $r->log_reason( "no uid found", $r->uri );
14             return AUTH_REQUIRED;
15             }
16             my @directives = @{ $r->requires };
17             $r->subprocess_env( ROLE => $role );
18             $r->log->info("$user with role $role EXPECTED");
19             for $req (@directives) {
20             my ( $require, @rest ) = split /\s+/, $req->{requirement};
21             if ( lc($directive) eq 'valid-user' ) {
22             $r->log->info("$user with role $role GRANTED");
23             return OK;
24             }
25              
26             if ( lc($require) eq "user" ) {
27             if ( grep { $_ eq $user } @rest ) {
28             $r->log->info("$user with role $role GRANTED");
29             return OK;
30              
31             }
32             }
33             }
34             return AUTH_REQUIRED;
35              
36             }
37             1;
38             __END__