| 1 | package DJabberd::Authen::AllowedUsers; | ||||||||||||||||||||||||||||||||
| 2 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 3 | 20 | ▶ | use base 'DJabberd::Authen'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 20 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||
| 6 | 20 | ▶ | use DJabberd::Log; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 20 | our $logger = DJabberd::Log->get_logger; | |||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 82 | ▶ | sub set_config_policy { | ||||||||||||||||||||||||||||||
|
Subroutine
set_config_policy: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 11 | 82 | my ($self, $policy) = @_; | |||||||||||||||||||||||||||||||
| 12 | 82 | $policy = lc $policy; | |||||||||||||||||||||||||||||||
| 13 | 82 | ▶ | croak("Policy must be 'deny' or 'accept'") unless $policy =~ /^deny|accept$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 14 | 82 | $self->{policy} = $policy; | |||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 41 | ▶ | sub set_config_allowedusers { | ||||||||||||||||||||||||||||||
|
Subroutine
set_config_allowedusers: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 18 | 41 | my ($self, $val) = @_; | |||||||||||||||||||||||||||||||
| 19 | 41 | ▶ | $self->{allowed} = ref $val ? $val : [ split(/\s+/, $val) ]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub set_config_deniedusers { | ||||||||||||||||||||||||||||||
|
Subroutine
set_config_deniedusers: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 23 | 0 | my ($self, $val) = @_; | |||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | $self->{denied} = ref $val ? $val : [ split(/\s+/, $val) ]; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||
| 27 | 41 | ▶ | sub finalize { | ||||||||||||||||||||||||||||||
|
Subroutine
finalize: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 28 | 41 | my $self = shift; | |||||||||||||||||||||||||||||||
| 29 | # just for error checking: | ||||||||||||||||||||||||||||||||
| 30 | 41 | $self->set_config_policy($self->{policy}); | |||||||||||||||||||||||||||||||
| 31 | 41 | ▶ | $self->{allowed} ||= []; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"allowed"} ||= []
MC/DC0%0/1
$self->{"allowed"} ||= []
$self->{"allowed"}
Truth table50%1/2
A
A= $self->{"allowed"}
| |||||||||||||||||||||||||||||||||
| 32 | 41 | ▶ | $self->{denied} ||= []; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"denied"} ||= []
MC/DC0%0/1
$self->{"denied"} ||= []
$self->{"denied"}
Truth table50%1/2
A
A= $self->{"denied"}
| |||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | sub check_cleartext { | ||||||||||||||||||||||||||||||
|
Subroutine
check_cleartext: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 36 | 0 | my ($self, $cb, %args) = @_; | |||||||||||||||||||||||||||||||
| 37 | 0 | my $user = $args{'username'}; | |||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | if ($self->{'policy'} eq "deny") { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 40 | 0 | $logger->debug("$self --- user=$user, denying, unless allowed: @{$self->{allowed}}"); | |||||||||||||||||||||||||||||||
| 41 | 0 | foreach my $allowed (@{$self->{allowed}}) { | |||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if (ref $allowed eq "Regexp" && $user =~ /$allowed/) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $allowed eq "Regexp" and $user =~ /$allowed/
MC/DC0%0/2
ref $allowed eq "Regexp" and $user =~ /$allowed/
ref $allowed eq "Regexp"
$user =~ /$allowed/
Truth table0%0/3
A and B
A= ref $allowed eq "Regexp"B= $user =~ /$allowed/
| |||||||||||||||||||||||||||||||||
| 43 | 0 | $cb->decline; # okay username, may continue in auth phase | |||||||||||||||||||||||||||||||
| 44 | 0 | return; | |||||||||||||||||||||||||||||||
| 45 | } elsif ($user eq $allowed) { | ||||||||||||||||||||||||||||||||
| 46 | 0 | $cb->decline; # okay username, may continue in auth phase | |||||||||||||||||||||||||||||||
| 47 | 0 | return; | |||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||
| 50 | 0 | $cb->reject; | |||||||||||||||||||||||||||||||
| 51 | 0 | return; | |||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if ($self->{'policy'} eq "accept") { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 55 | 0 | $logger->debug("$self --- user=$user, accepting, unless denied: @{$self->{denied}}"); | |||||||||||||||||||||||||||||||
| 56 | 0 | foreach my $allowed (@{$self->{denied}}) { | |||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if (ref $allowed eq "Regexp" && $user =~ /$allowed/) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $allowed eq "Regexp" and $user =~ /$allowed/
MC/DC0%0/2
ref $allowed eq "Regexp" and $user =~ /$allowed/
ref $allowed eq "Regexp"
$user =~ /$allowed/
Truth table0%0/3
A and B
A= ref $allowed eq "Regexp"B= $user =~ /$allowed/
| |||||||||||||||||||||||||||||||||
| 58 | 0 | $cb->reject; # okay username, may continue in auth phase | |||||||||||||||||||||||||||||||
| 59 | 0 | return; | |||||||||||||||||||||||||||||||
| 60 | } elsif ($user eq $allowed) { | ||||||||||||||||||||||||||||||||
| 61 | 0 | $cb->reject; # okay username, may continue in auth phase | |||||||||||||||||||||||||||||||
| 62 | 0 | return; | |||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||
| 65 | 0 | $cb->decline; | |||||||||||||||||||||||||||||||
| 66 | 0 | return; | |||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 0 | $cb->reject; | |||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 20 | 1; | |||||||||||||||||||||||||||||||