My goal is to have an LDAP server that I can bind to using a two-factor password (regular and OTP concatenated), and to have the password and yubikey ID stored in that LDAP server. Also, some users should have regular passwords only.
So far I've managed single-factor authentication like so:
- Simple bind to OpenLDAP
- OpenLDAP looks in the userPassword attribute. If it's a regular password ({CRYPT} or {SSHA}), authentication stops here. For Yubikey, it contains "{SASL}username".
- username and password are passed to saslauthd, which invokes PAM
- PAM calls pam_yubico, which checks the OTP against the validation server
- pam_yubico connects back to the LDAP server, retrieves the yubikeyID attribute for the user, and checks that it matches the validated OTP.
The only way I can think of to real two-factor auth is to set up a proxy LDAP server in front of the main one, where the main one contains a real password in userPassword, and the proxy replaces userPassword with {SASL}username if there's a yubikeyId attribute. PAM would then call pam_ldap to bind to the backend server using the real password, after pam_yubico has stripped the OTP off the end of the password string.
This seems like it's getting way too complicated, plus it would be a headache to keep the proxy in sync with the backend. Am I missing some easier way to do this? I'd think this would be a pretty common use case, but I can't find any documentation on this setup.