| 1 | package Web::Session::Store::LDAP; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Net::LDAP; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '1.0.0'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 19 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 19 | my ( $class, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 19 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 19 | ▶ | $self->{args} = $args if ( ref($args) eq 'HASH' ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 19 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | sub insert { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | my $session = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
MC/DC0%0/1
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
$self->{"args"}{"ldapObjectClass"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapObjectClass"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | $self->{args}->{ldapAttributeId} ||= 'cn'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeId"} ||= "cn"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeId"} ||= "cn"
$self->{"args"}{"ldapAttributeId"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeId"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | $self->{args}->{ldapAttributeContent} ||= 'description'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeContent"} ||= "description"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeContent"} ||= "description"
$self->{"args"}{"ldapAttributeContent"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeContent"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | $self->{args}->{ldapAttributeIndex} ||= 'ou'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
$self->{"args"}{"ldapAttributeIndex"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeIndex"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | my $index = | ||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | ref( $session->{args}->{Index} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ? $session->{args}->{Index} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | : [ split /\s+/, $session->{args}->{Index} ]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my $id = $session->{data}->{_session_id}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | my $attrIndex; | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | foreach my $i (@$index) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my $t; | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | next unless ( $t = $session->{data}->{$i} ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | push @$attrIndex, "${i}_$t"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | my $attrs = [ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | objectClass => $self->{args}->{ldapObjectClass}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | $self->{args}->{ldapAttributeId} => $session->{data}->{_session_id}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | $self->{args}->{ldapAttributeContent} => $session->{serialized}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | push @$attrs, ( $self->{args}->{ldapAttributeIndex} => $attrIndex ) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | if ($attrIndex); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | my $msg = $self->ldap->add( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | $self->{args}->{ldapAttributeId} . "=$id," | ||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | . $self->{args}->{ldapConfBase}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | attrs => $attrs, | |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | $self->ldap->unbind() && delete $self->{ldap}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | $self->logError($msg) if ( $msg->code ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $session = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
MC/DC0%0/1
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
$self->{"args"}{"ldapObjectClass"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapObjectClass"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | $self->{args}->{ldapAttributeId} ||= 'cn'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeId"} ||= "cn"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeId"} ||= "cn"
$self->{"args"}{"ldapAttributeId"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeId"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | $self->{args}->{ldapAttributeContent} ||= 'description'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeContent"} ||= "description"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeContent"} ||= "description"
$self->{"args"}{"ldapAttributeContent"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeContent"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $self->{args}->{ldapAttributeIndex} ||= 'ou'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
$self->{"args"}{"ldapAttributeIndex"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeIndex"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | my $index = | ||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ref( $session->{args}->{Index} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ? $session->{args}->{Index} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | : [ split /\s+/, $session->{args}->{Index} ]; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my $id = $session->{data}->{_session_id}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my $attrIndex; | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | foreach my $i (@$index) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $t; | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | next unless ( $t = $session->{data}->{$i} ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | push @$attrIndex, "${i}_$t"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | my $attrs = | ||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | { $self->{args}->{ldapAttributeContent} => $session->{serialized} }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | $attrs->{ $self->{args}->{ldapAttributeIndex} } = $attrIndex | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | if ($attrIndex); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | my $msg = $self->ldap->modify( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | $self->{args}->{ldapAttributeId} . "=" | ||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | . $session->{data}->{_session_id} . "," | ||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | . $self->{args}->{ldapConfBase}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | replace => $attrs, | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | $self->ldap->unbind() && delete $self->{ldap}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $self->logError($msg) if ( $msg->code ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub materialize { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
materialize: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $session = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
MC/DC0%0/1
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
$self->{"args"}{"ldapObjectClass"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapObjectClass"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | $self->{args}->{ldapAttributeId} ||= 'cn'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeId"} ||= "cn"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeId"} ||= "cn"
$self->{"args"}{"ldapAttributeId"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeId"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $self->{args}->{ldapAttributeContent} ||= 'description'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeContent"} ||= "description"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeContent"} ||= "description"
$self->{"args"}{"ldapAttributeContent"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeContent"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $self->{args}->{ldapAttributeIndex} ||= 'ou'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
$self->{"args"}{"ldapAttributeIndex"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeIndex"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | my $msg = $self->ldap->search( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | base => $self->{args}->{ldapAttributeId} . "=" | ||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | . $session->{data}->{_session_id} . "," | ||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | . $self->{args}->{ldapConfBase}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | filter => '(objectClass=' . $self->{args}->{ldapObjectClass} . ')', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | scope => 'base', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | attrs => [ $self->{args}->{ldapAttributeContent} ], | |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | $self->ldap->unbind() && delete $self->{ldap}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | $self->logError($msg) if ( $msg->code ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | $session->{serialized} = $msg->shift_entry() | ||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ->get_value( $self->{args}->{ldapAttributeContent} ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | if ( !defined $session->{serialized} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | die "Object does not exist in data store"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub remove { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $session = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $self->{args} = $session->{args}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | $self->{args}->{ldapObjectClass} ||= 'applicationProcess'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
MC/DC0%0/1
$self->{"args"}{"ldapObjectClass"} ||= "applicationProcess"
$self->{"args"}{"ldapObjectClass"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapObjectClass"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | $self->{args}->{ldapAttributeId} ||= 'cn'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeId"} ||= "cn"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeId"} ||= "cn"
$self->{"args"}{"ldapAttributeId"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeId"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | $self->{args}->{ldapAttributeContent} ||= 'description'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeContent"} ||= "description"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeContent"} ||= "description"
$self->{"args"}{"ldapAttributeContent"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeContent"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $self->{args}->{ldapAttributeIndex} ||= 'ou'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
MC/DC0%0/1
$self->{"args"}{"ldapAttributeIndex"} ||= "ou"
$self->{"args"}{"ldapAttributeIndex"}
Truth table0%0/2
A
A= $self->{"args"}{"ldapAttributeIndex"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | $self->ldap->delete( $self->{args}->{ldapAttributeId} . "=" | ||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | . $session->{data}->{_session_id} . "," | ||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | . $self->{args}->{ldapConfBase} ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | $self->ldap->unbind() && delete $self->{ldap}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub ldap { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ldap: not called CC=17 SCAR=57.2
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | return $self->{ldap} if $self->{ldap}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my @servers = $self->_parseServers; | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # Connect: first reachable server wins | ||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my ( $ldap, $srv, @errors ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | foreach my $s (@servers) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | $ldap = Net::LDAP->new( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | $s->{server}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | onerror => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | keepalive => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | %{ $s->{tlsParams} }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | $self->{args}->{ldapRaw} ? ( raw => $self->{args}->{ldapRaw} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | : () | ||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | $self->{args}->{ldapPort} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | ? ( port => $self->{args}->{ldapPort} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | : () | ||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | $self->{args}->{ldapTimeout} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | ? ( timeout => $self->{args}->{ldapTimeout} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | : () | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if ($ldap) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $srv = $s; | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | push @errors, "$s->{server}: " . ( $@ || 'unknown error' ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ || 'unknown error'
MC/DC0%0/1
$@ || 'unknown error'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | die( 'Unable to connect to ' | ||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | . join( ' ', map { $_->{server} } @servers ) . ": " | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | . join( ', ', @errors ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | unless $ldap; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | # Check SSL error for old Net::LDAP versions | ||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ( $Net::LDAP::VERSION < '0.64' ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | # CentOS7 has a bug in which IO::Socket::SSL will return a broken | ||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | # socket when certificate validation fails. Net::LDAP does not catch | ||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # it, and the process ends up crashing. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # As a precaution, make sure the underlying socket is doing fine. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # Note: IO::Socket::SSL may retain a stale or unrelated error message | ||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # (for example, "SSL wants a read first"), which can cause this check | ||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # to fail even when the socket is healthy. This workaround is only | ||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # required for older Net::LDAP versions (< 0.64). | ||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if ( $ldap->socket->isa('IO::Socket::SSL') | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ldap->socket->isa("IO::Socket::SSL") and $ldap->socket->errstr
MC/DC0%0/2
$ldap->socket->isa("IO::Socket::SSL") and $ldap->socket->errstr
$ldap->socket->isa("IO::Socket::SSL")
$ldap->socket->errstr
Truth table0%0/3
A and B
A= $ldap->socket->isa("IO::Socket::SSL")B= $ldap->socket->errstr
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | and $ldap->socket->errstr ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | die "SSL connection error: " . $ldap->socket->errstr; | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # Start TLS if needed | ||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | if ( $srv->{startTls} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my $mesg = $ldap->start_tls( %{ $srv->{tlsParams} } ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ( $mesg->code ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $self->logError($mesg); | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # I/O timeouts (set on the final socket, after StartTLS) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | if ( my $timeout = $self->{args}->{ldapIOTimeout} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | eval { require IO::Socket::Timeout; }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | die( 'IO::Socket::Timeout is required for ldapIOTimeout: ' . $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $socket = $ldap->socket; | |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | IO::Socket::Timeout->enable_timeouts_on($socket); | |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $socket->read_timeout($timeout); | |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $socket->write_timeout($timeout); | |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | # Bind | ||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $bind = $self->_bind( $ldap, $srv->{tlsParams} ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if ( $bind->code ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | $self->logError($bind); | |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $self->{ldap} = $ldap; | |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return $ldap; | |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | my @tlsKeys = qw(verify sslversion ciphers clientcert clientkey keydecrypt | |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | capath cafile checkcrl sslserver); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 8 | ▶ | sub _parseServers { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parseServers: called CC=15 SCAR=27.6
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 8 | my $args = $self->{args}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # Global defaults (compatibility: caFile/caPath) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | my %defaults = ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | cafile => $args->{ldapCAFile} || $args->{caFile}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | capath => $args->{ldapCAPath} || $args->{caPath}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | verify => $args->{ldapVerify} || 'require', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | clientcert => $args->{ldapClientCert}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | clientkey => $args->{ldapClientKey}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 8 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition62%5/8
$args->{'ldapCAFile'} || $args->{'caFile'}
$args->{'ldapCAPath'} || $args->{'caPath'}
$args->{'ldapVerify'} || 'require'
MC/DC50%1/2
$args->{'ldapCAFile'} || $args->{'caFile'}
$args->{'ldapCAFile'}
$args->{'caFile'}
MC/DC0%0/2
$args->{'ldapCAPath'} || $args->{'caPath'}
$args->{'ldapCAPath'}
$args->{'caPath'}
MC/DC100%1/1
$args->{'ldapVerify'} || 'require'
$args->{'ldapVerify'}
Truth table66%2/3
A || B
A= $args->{'ldapCAFile'}B= $args->{'caFile'}
Truth table33%1/3
A || B
A= $args->{'ldapCAPath'}B= $args->{'caPath'}
Truth table100%2/2
A
A= $args->{'ldapVerify'}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 8 | my @servers; | |||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 8 | foreach my $server ( split /[\s,]+/, $args->{ldapServer} ) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 10 | ▶ | next unless length $server; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 10 | my ( $startTls, $query ) = ( 0, '' ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 10 | ▶ | if ( $server =~ m{^ldap\+tls://([^/?]+)/?\??(.*)$} ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 1 | ( $server, $query, $startTls ) = ( $1, $2, 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | elsif ( $server =~ m{^(ldaps://[^/?]+)/?\??(.*)$} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 8 | ( $server, $query ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 10 | my %urlParams; | |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 10 | foreach ( split /&/, $query ) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 10 | my ( $k, $v ) = split /=/, $_, 2; | |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 10 | ▶ | $urlParams{$k} = $v if defined $k; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 10 | my %tlsParams; | |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 10 | foreach my $k (@tlsKeys) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | my $v = | ||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | ( defined $urlParams{$k} and length $urlParams{$k} ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ? $urlParams{$k} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 100 | ▶ | : $defaults{$k}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $urlParams{$k} and length $urlParams{$k}
MC/DC50%1/2
defined $urlParams{$k} and length $urlParams{$k}
defined $urlParams{$k}
length $urlParams{$k}
Truth table66%2/3
A and B
A= defined $urlParams{$k}B= length $urlParams{$k}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 100 | ▶ | $tlsParams{$k} = $v if defined $v and length $v; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $v and length $v
MC/DC50%1/2
defined $v and length $v
defined $v
length $v
Truth table66%2/3
A and B
A= defined $vB= length $v
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 10 | push @servers, | |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | server => $server, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | startTls => $startTls, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | tlsParams => \%tlsParams, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 8 | return @servers; | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 6 | ▶ | sub _bind { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bind: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 6 | my ( $self, $ldap, $tlsParams ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 6 | my $dn = $self->{args}->{ldapBindDN}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # Simple bind | ||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 6 | ▶ | if ( defined $dn and length $dn ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $dn and length $dn
MC/DC100%2/2
defined $dn and length $dn
defined $dn
length $dn
Truth table100%3/3
A and B
A= defined $dnB= length $dn
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | return $ldap->bind( $dn, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 2 | password => $self->{args}->{ldapBindPassword} ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # mTLS: SASL EXTERNAL | ||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | ▶ | elsif ( $ldap->socket->isa('IO::Socket::SSL') and $tlsParams->{clientcert} ) | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$ldap->socket->isa("IO::Socket::SSL") and $tlsParams->{"clientcert"}
MC/DC100%2/2
$ldap->socket->isa("IO::Socket::SSL") and $tlsParams->{"clientcert"}
$ldap->socket->isa("IO::Socket::SSL")
$tlsParams->{"clientcert"}
Truth table100%3/3
A and B
A= $ldap->socket->isa("IO::Socket::SSL")B= $tlsParams->{"clientcert"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | eval { require Authen::SASL; }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | die( 'Authen::SASL is required for EXTERNAL binding: ' . $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | my $sasl = Authen::SASL->new( | |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | mechanism => 'EXTERNAL', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | callback => { user => '' } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 1 | return $ldap->bind( undef, sasl => $sasl ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # Anonymous | ||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 3 | return $ldap->bind(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | sub logError { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logError: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my $ldap_operation = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | die "LDAP error " . $ldap_operation->code . ": " . $ldap_operation->error; | |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | Web::Session::Store::LDAP - Use LDAP to store persistent objects | ||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | use Web::Session::Store::LDAP; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | my $store = new Web::Session::Store::LDAP; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | $store->insert($ref); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | $store->update($ref); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | $store->materialize($ref); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | $store->remove($ref); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | This module fulfills the storage interface of Apache::Session. The serialized | ||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | objects are stored in an LDAP directory file using the Net::LDAP Perl module. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | =head1 OPTIONS | ||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | Required: B<ldapServer> and B<ldapConfBase>. All others are optional. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | Example: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | tie %s, 'Web::Session::LDAP', undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | ldapServer => 'ldaps://ldap.example.com/?verify=require', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | ldapConfBase => 'ou=sessions,dc=example,dc=com', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ldapBindDN => 'cn=admin,dc=example,dc=com', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | ldapBindPassword => 'pass', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | Index => 'uid ipAddr', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | =item ldapServer | ||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | Space or comma separated list of servers, tried in order (failover). Each | ||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | entry is one of: | ||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | host[:port] | ldap://host[:port] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | ldaps://host[:port][/?params] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | ldap+tls://host[:port][/?params] (StartTLS) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | C<params> is a C<key=value&...> list of TLS options overriding the global ones | ||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | for this server. Allowed keys: verify, sslversion, ciphers, clientcert, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | clientkey, keydecrypt, capath, cafile, checkcrl, sslserver. Other keys are | ||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | ignored. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | =item ldapConfBase | ||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | DN under which sessions are stored. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | =item ldapBindDN, ldapBindPassword | ||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | Credentials for a simple bind. Without ldapBindDN, the connection binds with | ||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | SASL EXTERNAL if it uses TLS with a client certificate, anonymously otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | =item ldapVerify | ||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | Server certificate verification: C<none>, C<optional> or C<require> (default). | ||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | =item ldapCAFile, ldapCAPath | ||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | CA file/directory used to verify the server certificate. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | =item ldapClientCert, ldapClientKey | ||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | Client certificate and key (PEM) for mutual TLS. The key may be omitted if | ||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | included in the certificate file. SASL EXTERNAL requires L<Authen::SASL>. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | =item ldapTimeout | ||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | Connection timeout (seconds). | ||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | =item ldapIOTimeout | ||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | Read/write timeout (seconds). Requires L<IO::Socket::Timeout>. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | =item ldapPort | ||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | Default port. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | =item ldapRaw | ||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | Regex of attributes returned as raw binary (see L<Net::LDAP>). | ||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | =item ldapObjectClass, ldapAttributeId, ldapAttributeContent, ldapAttributeIndex | ||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | Object class (default C<applicationProcess>) and attributes used for the | ||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | session id (C<cn>), serialized content (C<description>) and indexes (C<ou>). | ||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | =item 2009-2026 by Xavier Guimard | ||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | =item 2013-2025 by Clément Oudot | ||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | =item 2019-2025 by Maxime Besson | ||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | =item 2013-2025 by Worteks | ||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | =item 2023-2026 by Linagora | ||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | =item 2026 by Christophe Maudoux | ||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | it under the same terms as Perl itself, either Perl version 5.10.0 or, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | at your option, any later version of Perl 5 you may have available. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | L<Apache::Session> | ||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||