I wasn't able to find an example on the web about this and it took me some days to pick up the widespread details. Here is how I fit it together so others can find an example now.
For a proper Proxy Authorization with SASL/GSSAPI, that needs a Kerberos authentication, we have to specify a Kerberos principal that is used as proxy user. Then for SASL authentication on the ldap server we need the usual user mapping from the SASL auth dn to the ldap account. Now we can setup the Proxy Authorization.
Create Kerberos principal
I create anyuser to use its authentication as proxy for any user. I need it for GSSAPI authentication on client devices.
~$ kadmin -p somebody/admin addprinc -policy user anyuser
Authentication mapping
This is the usual distinguished name (dn) mapping as described in the OpenLDAP Software 2.4 Administrator's Guide about Mapping Authentication Identities.
~$ cat > /tmp/in.ldif <<EOF
dn: cn=config
changetype: modify
add: olcAuthzRegexp
olcAuthzRegexp:
{0}uid=([^,]*),cn=gssapi,cn=auth
uid=\$1,ou=people,ou=home,dc=hoeft-online,dc=de
-
add: olcAuthzRegexp
olcAuthzRegexp:
{1}uid=([^,]*),cn=home.hoeft-online.de,cn=gssapi,cn=auth
uid=\$1,ou=people,ou=home,dc=hoeft-online,dc=de
EOF
~$ sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f /tmp/in.ldif
Test the mapping with:
~$ kinit ingo
~$ ldapwhoami -Y GSSAPI -v
ldap_initialize( <DEFAULT> )
SASL/GSSAPI authentication started
SASL username: ingo@HOME.HOEFT-ONLINE.DE
SASL SSF: 256
SASL data security layer installed.
dn:uid=ingo,ou=people,ou=home,dc=hoeft-online,dc=de
Result: Success (0)
Proxy Authorization is disabled by default. So first we have to enable it on the ldap server. I only want to use authzTo attributes. For possible settings look at man slapd-config
for olcAuthzPolicy
.
~$ cat > /tmp/in.ldif <<EOF
dn: cn=config
changetype: modify
add: olcAuthzPolicy
olcAuthzPolicy: to
EOF
~$ sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f /tmp/in.ldif
# For this modify is a restart needed
~$ sudo systemctl restart slapd.service
Now I create an anyuser posix account used as proxy. For setting the authzTo
attribute look at Mapping Authentication Identities.
~$ cat > /tmp/in.ldif <<EOF
dn: cn=anyuser,ou=group,ou=home,dc=hoeft-online,dc=de
objectClass: top
objectClass: posixGroup
cn: anyuser
gidNumber: 1001
dn: uid=anyuser,ou=people,ou=home,dc=hoeft-online,dc=de
objectClass: top
objectClass: person
objectClass: posixAccount
objectClass: shadowAccount
uid: anyuser
uidNumber: 1001
gidNumber: 1001
cn: any
sn: user
loginShell: /usr/sbin/nologin
homeDirectory: /nonexistent
authzTo: dn.regex:^uid=[^,]*,ou=people,ou=home,dc=hoeft-online,dc=de$
EOF
~$ sudo slapadd -l /tmp/in.ldif
Now you can test the Proxy Authorization with:
~$ kinit -p ingo
~$ ldapwhoami -Y GSSAPI -D "uid=anyuser,ou=people,ou=home,dc=hoeft-online,dc=de"
SASL/GSSAPI authentication started
SASL username: ingo@HOME.HOEFT-ONLINE.DE
SASL SSF: 256
SASL data security layer installed.
dn:uid=ingo,ou=people,ou=home,dc=hoeft-online,dc=de
Please also note from Proxy Authorization Rules:
Source rules are extremely powerful. If ordinary users have access to write the authzTo attribute in their own entries, then they can write rules that would allow them to authorize as anyone else. As such, when using source rules, the authzTo attribute should be protected with an ACL that only allows privileged users to set its values.