deploying openLDAP

LDAP configuration


As of the Grid release, tDAR is capable of authenticating via LDAP. This could be as
complex as an Institutional ActiveDirectory system or as simple as a small
standalone install of openLDAP on the local system. openLDAP is fairly simple to
set up and configure, provided you know where all the required configurable params
are located. As such, in the files below, important sections will be highlighted for
your convenience.

Please note, this guide assumes you are installing openLDAP on a Unix (or other posix
compliant) system.

Please note also that tDAR still uses Atlassian Crowd as its default authentication provider.
You'll need to make some minor changes to tDAR's configuration, and these are
detailed at the end of this document.

Setting up openLDAP

Using your favorite package manager, install the packages openldap, openldap-clients,
openldap-servers, openldap-devel and compat-openldap. Alternatively, they (and
their source) can be obtained at http://www.openldap.org/software/download/

After they are installed, you'll need to alter the configuration before starting slapd.
This can be quite complex. On RHEL, the config is stored in /etc/openldap/, in the
files ldap.conf, slapd.conf and in the slap.d/ directory structure.

Both ldap.conf and slapd.conf come pre-filled with most of the settings required.
You will still need to define a BASE DN and configure a Manager account.

Ensure you make all instances of the example BASE DN ('dc=example,dc=com') are
changed to the correct BASE DN for your institution, or to whatever custom DN you'd
like to use. It is also important to set the root password something more secure than
the default ('secret').

EXAMPLE ldap.conf

#
# LDAP Defaults
#

# See ldap.conf(5) for details
# This file should be world readable but not world writable.

# BASE sets the BASE DN of the whole directory. All instances should match.
BASE   dc=example,dc=com
# URI should include all locations from which this directory will be called.
URI    ldap://localhost:389 ldap://ldap.example.com ldap://ldap-master.example.com:666

#SIZELIMIT      12
#TIMELIMIT      15
#DEREF          never

EXAMPLE slapd.conf

# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#

include     /etc/openldap/schema/corba.schema
include     /etc/openldap/schema/core.schema
include     /etc/openldap/schema/cosine.schema
include     /etc/openldap/schema/duaconf.schema
include     /etc/openldap/schema/dyngroup.schema
include     /etc/openldap/schema/inetorgperson.schema
include     /etc/openldap/schema/java.schema
include     /etc/openldap/schema/misc.schema
include     /etc/openldap/schema/nis.schema
include     /etc/openldap/schema/openldap.schema
include     /etc/openldap/schema/ppolicy.schema
include     /etc/openldap/schema/collective.schema

# Allow LDAPv2 client connections.  This is NOT the default.
allow bind_v2

# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral   ldap://root.openldap.org

pidfile     /var/run/openldap/slapd.pid
argsfile    /var/run/openldap/slapd.args

# Load dynamic backend modules
# - modulepath is architecture dependent value (32/64-bit system)
# - back_sql.la overlay requires openldap-server-sql package
# - dyngroup.la and dynlist.la cannot be used at the same time

# modulepath /usr/lib/openldap
# modulepath /usr/lib64/openldap

# moduleload accesslog.la
# moduleload auditlog.la
# moduleload back_sql.la
# moduleload chain.la
# moduleload collect.la
# moduleload constraint.la
# moduleload dds.la
# moduleload deref.la
# moduleload dyngroup.la
# moduleload dynlist.la
# moduleload memberof.la
# moduleload pbind.la
# moduleload pcache.la
# moduleload ppolicy.la
# moduleload refint.la
# moduleload retcode.la
# moduleload rwm.la
# moduleload seqmod.la
# moduleload smbk5pwd.la
# moduleload sssvlv.la
# moduleload syncprov.la
# moduleload translucent.la
# moduleload unique.la
# moduleload valsort.la

# The next three lines allow use of TLS for encrypting connections using a
# dummy test certificate which you can generate by changing to
# /etc/pki/tls/certs, running "make slapd.pem", and fixing permissions on
# slapd.pem so that the ldap user or group can read it.  Your client software
# may balk at self-signed certificates, however.
# TLSCACertificateFile /etc/pki/tls/certs/ca-bundle.crt
# TLSCertificateFile /etc/pki/tls/certs/slapd.pem
# TLSCertificateKeyFile /etc/pki/tls/certs/slapd.pem
# Sample security restrictions
#   Require integrity protection (prevent hijacking)
#   Require 112-bit (3DES or better) encryption for updates
#   Require 63-bit encryption for simple bind
# security ssf=1 update_ssf=112 simple_bind=64

# Sample access control policy:
#   Root DSE: allow anyone to read it
#   Subschema (sub)entry DSE: allow anyone to read it
#   Other DSEs:
#       Allow self write access
#       Allow authenticated users read access
#       Allow anonymous users to authenticate
#   Directives needed to implement policy:
# access to dn.base="" by * read
# access to dn.base="cn=Subschema" by * read
# access to *
#   by self write
#   by users read
#   by anonymous auth
#
# if no access controls are present, the default policy
# allows anyone and everyone to read anything but restricts
# updates to rootdn.  (e.g., "access to * by * read")
#
# rootdn can always read and write EVERYTHING!

# enable on-the-fly configuration (cn=config)
database config
access to *
    by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" manage
    by * none

# enable server status monitoring (cn=monitor)
database monitor
access to *
    by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read
        by dn.exact="cn=Manager,dc=example,dc=com" read
        by * none

#######################################################################
# database definitions
#######################################################################

database    bdb
suffix      "dc=example,dc=com"
checkpoint  1024 15
rootdn      "cn=Manager,dc=example,dc=com"
# Cleartext passwords, especially for the rootdn, should
# be avoided.  See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.

rootpw        {crypt}ijFYNcSNctBYg

# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory   /usr/local/openldap/var/openldap-data

# Indices to maintain for this database
index objectClass                       eq,pres
index ou,cn,mail,surname,givenname      eq,pres,sub
index uidNumber,gidNumber,loginShell    eq,pres
index uid,memberUid                     eq,pres,sub
index nisMapName,nisMapEntry            eq,pres,sub

# Replicas of this database
#replogfile /var/lib/ldap/openldap-master-replog
#replica host=ldap-1.example.com:389 starttls=critical
#     bindmethod=sasl saslmech=GSSAPI
#     authcId=host/ldap-master.example.com@EXAMPLE.COM

slap.d directory configuration


Most of the default configuration under the slap.d/ directory can remain untouched.
There are, however, a few critical locations where settings must be customized. The
following files have BASE DN entries that must be made to match those in the
previously modified configuration.

EXAMPLE cn=config/olcDatabase={1}monitor.ldif

dn: olcDatabase={1}monitor
objectClass: olcDatabaseConfig
olcDatabase: {1}monitor
olcAccess: {0}to *  by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=externa
 l,cn=auth" read  by dn.base="cn=Manager,dc=example,dc=com" read  by * none
olcAddContentAcl: FALSE
olcLastMod: TRUE
olcMaxDerefDepth: 15
olcReadOnly: FALSE
olcSyncUseSubentry: FALSE
olcMonitoring: FALSE
structuralObjectClass: olcDatabaseConfig
entryUUID: 90c2bed6-f16d-1030-9f5c-c14c9a23456
creatorsName: cn=config
createTimestamp: 20120222065243Z
entryCSN: 20120222065243.948460Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20120222065243Z

EXAMPLE cn=config/olcDatabase={2}bdb.ldif

dn: olcDatabase={2}bdb
objectClass: olcDatabaseConfig
objectClass: olcBdbConfig
olcDatabase: {2}bdb
olcSuffix: dc=example,dc=com
olcAddContentAcl: FALSE
olcLastMod: TRUE
olcMaxDerefDepth: 15
olcReadOnly: FALSE
olcRootDN: cn=Manager,dc=example,dc=com
olcRootPW: secret
olcSyncUseSubentry: FALSE
olcMonitoring: TRUE
olcDbDirectory: /var/lib/ldap
olcDbCacheSize: 1000
olcDbCheckpoint: 1024 15
olcDbNoSync: FALSE
olcDbDirtyRead: FALSE
olcDbIDLcacheSize: 0
olcDbIndex: objectClass pres,eq
olcDbIndex: cn pres,eq,sub
olcDbIndex: uid pres,eq,sub
olcDbIndex: uidNumber pres,eq
olcDbIndex: gidNumber pres,eq
olcDbIndex: mail pres,eq,sub
olcDbIndex: ou pres,eq,sub
olcDbIndex: loginShell pres,eq
olcDbIndex: sn pres,eq,sub
olcDbIndex: givenName pres,eq,sub
olcDbIndex: memberUid pres,eq,sub
olcDbIndex: nisMapName pres,eq,sub
olcDbIndex: nisMapEntry pres,eq,sub
olcDbLinearIndex: FALSE
olcDbMode: 0600
olcDbSearchStack: 16
olcDbShmKey: 0
olcDbCacheFree: 1
olcDbDNcacheSize: 0
structuralObjectClass: olcBdbConfig
entryUUID: 90c2c41c-f16d-1030-9f5d-c14c9a23456
creatorsName: cn=config
createTimestamp: 20120222065243Z
entryCSN: 20120222065243.948460Z#000000#000#000000
modifiersName: cn=config
modifyTimestamp: 20120222065243Z

Final Steps


We use an application called LDAP Account Manager (LAM) to administer our LDAP environment.
LDAP's command line tools require an appropriately formatted text file even for the simplest
of searches, so a web based frontend is a reasonable alternative.

Packages for Debian, Fedora and SUSE are availabe from http://www.ldap-account-manager.org.

When LDAP Account Manager is installed it can be accessed via http://localhost/lam on your
server. The installer will add some rules to your apache configuration, but these may be precluded
by other rules normally used in tdar's configuration. Here's an example conf.d configuration file for
use when running tDAR under a servlet handler on port 8080, which will allow for LAM to be
accessible under its standard configuration.

# Don't access HTTP proxy requests
# (this is a reverse proxy, not a forward proxy)
ProxyRequests off

# Any user may connect
<Proxy *>
Order deny,allow
Allow from all
</Proxy>

#Don't proxy account manager
ProxyPass        /lam !


# Proxy everything to tDAR
<Location / >
ProxyPass        http://localhost:8080/
ProxyPassReverse http://localhost:8080/
</Location>

LDAP Account Manager can detect issues with the configuration tree and can rectify them
automatically. You will need to create two LDAP groups, however: tdar-users and tdar-admins.

It is, of course, necessary to tell tDAR to use the LDAP authentication service in
spring-local-settings.xml. Here's an example of how that should look.

<?xml version="1.0"?>
<!--
vim:sts=2:sw=2:
-->
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       ">

  <import resource="pooling/c3p0.xml" />
  <import resource='spring-ldap.xml' />

</beans>

Restart tDAR to see these changes take effect.

Congratulations! You've just linked your tDAR install to your local LDAP directory.