<!-- 'enabled' is the master switch; set to 'true' to enable proxied logins -->
<enabled>false</enabled>
<authenticators>
- <!-- the following is a sample configuration for the LDAP_Auth module; please adjust as needed -->
+ <!--
+ The following is a sample configuration for the
+ LDAP_Auth module; please adjust as needed.
+
+ For LDAPS, configure the start_tls block as follows
+ (note that the server must support LDAPv3 with the
+ LDAP_EXTENSION_START_TLS extension):
+ - enabled: true or false
+ - verify: none, optional, or require (default: require)
+ - cafile: path to PEM cert of CA who signed the server's cert
+ See the Perl Net::LDAP documentation for details.
+ -->
<!--
<authenticator>
<name>ldap</name>
<unit>103</unit>
<unit>104</unit>
</org_units>
+ <start_tls>
+ <enabled>false</enabled>
+ <verify>require</verify>
+ <cafile>/etc/ssl/certs/cacert.pem</cafile>
+ </start_tls>
</authenticator>
-->
<!-- 'native' is a proxied version of Evergreen's standard authentication -->
}
my $hostname_is_ldap = 0;
+ my $handled_tls = 0;
my $reached_ldap = 0;
my $user_in_ldap = 0;
my $login_succeeded = 0;
my $ldap;
if ( $ldap = Net::LDAP->new($hostname) ) {
$hostname_is_ldap = 1;
+
+ # check for LDAPS config; if enabled, establish secure connection
+ my $tls = $self->{'start_tls'};
+ if (ref $tls and $tls->{'enabled'} eq 'true') {
+ if ( $ldap->start_tls(
+ verify => $tls->{'verify'},
+ cafile => $tls->{'cafile'}) ) {
+ $handled_tls = 1;
+ }
+ } else {
+ # When TLS is not enabled, we handle it successfully
+ # by not attempting to use it.
+ $handled_tls = 1;
+ }
+
if ( $ldap->bind( $authid, password => $authid_pass )->code == 0 ) {
$reached_ldap = 1;
# verify username and lookup user's DN
# TODO: custom failure events?
$logger->debug("User login failed: Incorrect LDAP hostname");
return OpenILS::Event->new( 'LOGIN_FAILED' );
+ } elsif ( !$handled_tls ) {
+ $logger->debug("User login failed: Could not establish TLS connection to LDAP server");
+ return OpenILS::Event->new( 'LOGIN_FAILED' );
} elsif ( !$reached_ldap ) {
$logger->debug("User login failed: The LDAP server is misconfigured or unavailable");
return OpenILS::Event->new( 'LOGIN_FAILED' );