Difference between revisions of "Openldap"

From PostgreSQL_wiki
Jump to: navigation, search
(pam.d)
(pam.d)
 
(One intermediate revision by the same user not shown)
Line 86: Line 86:
 
common-account
 
common-account
 
<pre>
 
<pre>
account sufficient pam_unix.so
+
account [success=2 new_authtok_reqd=done default=ignore] pam_unix.so
account sufficient pam_ldap.so
+
account [success=1 default=ignore] pam_ldap.so
account required pam_deny.so
+
account requisite pam_deny.so
  +
account required pam_permit.so
 
</pre>
 
</pre>
 
common-auth
 
common-auth
 
<pre>
 
<pre>
  +
auth [success=2 default=ignore] pam_unix.so nullok_secure try_first_pass
auth sufficient pam_ldap.so
 
auth sufficient pam_unix.so shadow use_first_pass
+
auth [success=1 default=ignore] pam_ldap.so use_first_pass
auth required pam_deny.so
+
auth requisite pam_deny.so
  +
auth required pam_permit.so
 
</pre>
 
</pre>
 
common-password
 
common-password
 
<pre>
 
<pre>
  +
password [success=2 default=ignore] pam_unix.so obscure ssha # sha512
password requisite pam_passwdqc.so min=12,10,10,8,6 random=25 retry=3 passphrase=2
 
password sufficient pam_ldap.so type=network use_authtok first_pass
+
password [success=1 user_unknown=ignore default=die] pam_ldap.so use_authtok try_first_pass ssha
  +
password requisite pam_deny.so
password sufficient pam_unix.so type=machine use_authtok md5
 
password required pam_deny.so
+
password required pam_permit.so
 
</pre>
 
</pre>
common-session
+
common-session<br/>
  +
In de laatste regel van deze snippet zorgt het systeem ervoor dat de directory /home aanwezig is.
 
<pre>
 
<pre>
  +
session [default=1] pam_permit.so
session sufficient pam_ldap.so
 
session required pam_unix.so
+
session requisite pam_deny.so
  +
session required pam_permit.so
  +
session required pam_unix.so
  +
session optional pam_ldap.so
  +
  +
session required pam_mkhomedir.so skel=/etc/skel umask=0022
 
</pre>
 
</pre>
 
common-session-noninteractive
 
common-session-noninteractive
 
<pre>
 
<pre>
  +
session [default=1] pam_permit.so
#
 
  +
session requisite pam_deny.so
# /etc/pam.d/common-session-noninteractive - session-related modules
 
  +
session required pam_permit.so
# common to all non-interactive services
 
  +
session required pam_unix.so
#
 
  +
session optional pam_ldap.so
# This file is included from other service-specific PAM config files,
 
# and should contain a list of modules that define tasks to be performed
 
# at the start and end of all non-interactive sessions.
 
#
 
# As of pam 1.0.1-6, this file is managed by pam-auth-update by default.
 
# To take advantage of this, it is recommended that you configure any
 
# local modules either before or after the default block, and use
 
# pam-auth-update to manage selection of other modules. See
 
# pam-auth-update(8) for details.
 
 
# here are the per-package modules (the "Primary" block)
 
session [default=1] pam_permit.so
 
# here's the fallback if no module succeeds
 
session requisite pam_deny.so
 
# prime the stack with a positive return value if there isn't one already;
 
# this avoids us returning an error just because nothing sets a success code
 
# since the modules above will each just jump around
 
session required pam_permit.so
 
# and here are more per-package modules (the "Additional" block)
 
session required pam_unix.so
 
session optional pam_ldap.so
 
 
# end of pam-auth-update config
 
# end of pam-auth-update config
 
</pre>
 
</pre>

Latest revision as of 15:15, 23 November 2011

openLDAP is een open source implementatie van de LDAP standaard. De openLDAP implementatie is onder Squeeze ingrijpend gewijzigd ten opzichte van eerdere versies van de Debian implementatie.

  • TLS in plaats van openSSL
  • syncrepl in plaats van updateref, het provider consumer model
  • Gebruik van een soort slap.d database inplaats van /etc/ldap/slapd.conf

Opzet openldap configuratie

De gebruikelijke configuratie met slapd.conf is verleden tijd, het mag nog wel, maar deze methode is depricated. De nieuwe manier van configureren werkt met een dynamische ldif structuur.

Secure openldap

Het openldap project is overgegaan op TLS, maar Webhuis gebruikt de certificaten die met openssl zijn aangemaakt.

Testen van de configuratie

ldapsearch localhost
ldapsearch lokaal op IP adres
ldapsearch remote op IP adres

Secrets

Raar maar waar uit de documentatie blijkt:

  • ldap.conf passd staat in libnss-ldap.secret
  • libnss-ldap.conf passwd staat in ldap.secret
  • pam_ldap.conf passwd staat in ldap.secret

Tooling

Phpldapadmin is een eenvoudig webbased ldap tool.
Bij Squeeze is een onhebbelijkheid in de configuratie geslopen, phpldapadmin vraagt bij elke actie een template te kiezen. Zet dit uit door in /etc/phpldapadmin/config.php de parameter:

// $config->custom->appearance['custom_templates_only'] = false;

te wijzigen in:
$config->custom->appearance['custom_templates_only'] = true;

Provider

Opzeten Provider (Master) voor meerdere domeinen.
OpenLDAP is in de nieuwe opzet veel flexibeler dan voorheen, waardoor het mogelijk is om de replicatie vanuit verschillende bronnen te laten plaatsvinden. Een traditionele "slave" kan zo voor bepaalde attributen wijzigingen accepteren en die doorgeven aan de Master.
Voorbeelden:

  • PTR records van machines in een subnet
  • Password wijzigingen door gebruikers

Multple domains

openLDAP maakt gebruik van de cn=config methode van configureren, de methode met slapd.conf is depricated. Bijna alle documentatie in de Administrator guide baseert zich echter nog op de oude methode met slapd.conf. Met name de ondersteuning van meerdere domains in de configuratie met de cn=config methode is anno 2011 nog moeilijk vast te stellen. Onder staat de listing van /etc/ldap/slapd.d/cn=config.

drwxr-x--- 2 openldap openldap  4096 Apr 24 12:44 cn=schema
drwxr-x--- 2 openldap openldap  4096 Apr 25 13:00 olcDatabase={1}bdb
drwxr-x--- 2 openldap openldap  4096 Sep 21 21:17 olcDatabase={2}bdb
-rw------- 1 openldap openldap   392 Apr 24 12:44 cn=module{0}.ldif
-rw------- 1 openldap openldap 36830 Apr 24 12:44 cn=schema.ldif
-rw------- 1 openldap openldap   525 Apr 24 12:44 olcDatabase={-1}frontend.ldif
-rw------- 1 openldap openldap   513 Apr 24 12:44 olcDatabase={0}config.ldif
-rw------- 1 openldap openldap  4652 Sep 23 00:13 olcDatabase={1}bdb.ldif
-rw------- 1 openldap openldap  4664 Sep 21 21:14 olcDatabase={2}bdb.ldif

Proefondervindelijk heeft Webhuis vastgesteld dat er naast een Database-bdb.ldif bestand tevens een Database-bdb directory aanwezig moete zijn.

slapadd -n 1 -l /usr/local/src/samba-ldap/init-base.ldif
slapadd -n 1 -l /usr/local/src/samba-ldap/ldap-populate.ldif
slapadd -n 2 -l /usr/local/src/samba-ldap/wbhs-m.webhuis.nl.ldif

Consumer

Replicatie tussen provider en consumer

Server (slapd) configuratie

gnutls-cli -s uwork-p.uwork.nl -p 636 gnutls-cli -s uwork-p.uwork.nl -p 636 in een ander venster pkill -ALRM gnutls-cli

Client (ldap) configuratie

Stapsgewijs beschikbaar maken van de LDAP directory voor meerdere doeleinden en op meerdere plaatsen. Een aardig inzicht in de opzet geeft:

ldap.conf

De ldap client configuratie is vrij eenvoudig:

uri ldap://ldap1.cs.school.edu/ ldap://ldap2.cs.school.edu
base dc=cs,dc=school,dc=edu
ldap_version 3
ssl start_tls
TLS_CACERT /etc/ldap/ssl/cacert.pem

nss_base_netgroup      cn=netgroup,dc=cs,dc=school,dc=edu?one

Het volgende maakt het op client niveau allemaal stukken eenvoudiger:

rm -f /etc/libnss-ldap.conf
rm -f /etc/pam_ldap.conf
ln -s /etc/ldap/ldap.conf /etc/libnss-ldap.conf
ln -s /etc/ldap/ldap.conf /etc/pam_ldap.conf

pam.d

common-account

account  [success=2 new_authtok_reqd=done default=ignore] pam_unix.so
account  [success=1 default=ignore]                       pam_ldap.so
account  requisite                                        pam_deny.so
account  required                                         pam_permit.so

common-auth

auth     [success=2 default=ignore]                       pam_unix.so nullok_secure try_first_pass
auth     [success=1 default=ignore]                       pam_ldap.so use_first_pass
auth     requisite                                        pam_deny.so
auth     required                                         pam_permit.so

common-password

password [success=2 default=ignore]                       pam_unix.so obscure ssha # sha512
password [success=1 user_unknown=ignore default=die]      pam_ldap.so use_authtok try_first_pass ssha
password requisite                                        pam_deny.so
password required                                         pam_permit.so

common-session
In de laatste regel van deze snippet zorgt het systeem ervoor dat de directory /home aanwezig is.

session  [default=1]                                      pam_permit.so
session  requisite                                        pam_deny.so
session  required                                         pam_permit.so
session  required                                         pam_unix.so
session  optional                                         pam_ldap.so

session  required                                         pam_mkhomedir.so skel=/etc/skel umask=0022

common-session-noninteractive

session  [default=1]                                      pam_permit.so
session  requisite                                        pam_deny.so
session  required                                         pam_permit.so
session  required                                         pam_unix.so
session  optional                                         pam_ldap.so
# end of pam-auth-update config

nfs

dn: cn={6}autofs
objectClass: olcSchemaConfig
cn: {6}autofs
olcAttributetypes: {0}( 1.3.6.1.1.1.1.25 NAME 'automountInformation'
 DESC 'Information used by the autofs automounter'
 EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )

olcObjectClasses: {1}( 1.3.6.1.1.1.1.13 NAME 'automount' SUP top STRUCTURAL
 DESC 'An entry in an automounter map'
 MUST ( cn $ automountInformation $ objectclass )
 MAY ( description ) )

olcObjectClasses: {2}( 1.3.6.1.4.1.2312.4.2.2 NAME 'automountMap' SUP top STRUCTURAL
 DESC 'An group of related automount objects'
 MUST ( ou ) )


synrepl

authentication voor services met ldap


Terug naar: Webhuis Infrastructuur