Description
I'm trying to integrate Kerberos KDC configuration and wanted to add an issue to track progress, ask help, and probably vent a bit. :-) I've checked the earlier kerberos issues.
Ideally this will be integrated into the one-time setup and controlled by an env var like 'USE_KDC=1'
Here's what I have so far... oddly the openldap container fails the first time I run docker-compose up but succeeds afterwards. I'll update this later unless I get so frustrated with Docker that I end up finishing this up with an ansible script.
Preparation
-
Download the kerberos source (apt-get source krb5). /usr/share/doc/krb5-kdc-ldap is similar but doesn't include kerberos.openldap.ldif. That file strips out some things already present in a standard openldap configuation.
-
Copy src/plugins/kdb/ldap/libkdb_ldap/kerberos.schema to bootstrap/schema
-
Copy src/plugins/kdb/ldap/libkdb_ldap/kerberos.openldap.ldif to bootstrap/ldif
-
Create krb5 directory
-
Add krb5/kdc.conf
[libdefaults] default_realm = EXAMPLE.COM kdc_timesync = 1 ccache_type = 4 forwardable = true proxiable = true [realms] EXAMPLE.COM = { kdc = localhost admin_server = localhost default_domain = example.com } [domain_realm] .example.com = EXAMPLE.COM example.com = EXAMPLE.COM
-
Add krb5/kdc.conf
[kdcdefaults] kdc_ports = 750,88 [realms] EXAMPLE.COM = { database_module = LDAP # database_name = /var/lib/krb5kdc/principal admin_keytab = FILE:/etc/krb5kdc/kadm5.keytab # acl_file = /etc/krb5kdc/kadm5.acl key_stash_file = /etc/krb5kdc/stash kdc_ports = 750,88 max_life = 10h 0m 0s max_renewable_life = 7d 0h 0m 0s master_key_type = des3-hmac-sha1 #supported_enctypes = aes256-cts:normal aes128-cts:normal default_principal_flags = +preauth } [dbmodules] LDAP = { db_library = kldap ldap_kerberos_container_dn = cn=krbContainer,dc=example,dc=com ldap_kdc_dn = cn=admin,dc=example,dc=com ldap_kadmind_dn = cn=admin,dc=example,dc=com ldap_service_password_file = /etc/krb5kdc/ldap.stash ldap_servers = ldapi:/// }
-
Add this to Dockerfile
ADD krb5/krb5.conf /etc/krb5.conf ADD krb5/kdc.conf /etc/krb5kdc/kdc.conf
Configuration
This is still done manually. I don't know if there's already a hook, similar to bootstrap, that allows us to run an arbitrary script before or after the openldap server is up.
Note: best practices would probably include creating an LDAP entry specifically for the KDC and KADMIND admin roles instead of reusing cn=admin.
-
Add ou=users. (And ou=systems ?)
-
Stash ldap key. I don't know if you can specify the
kdb5_ldap_util stashsrvpw cn=admin,dc=example,dc=com
-
Initialize the KDC entries in LDAP
kdb5_ldap_util -D cn=admin,dc=snapdevteam,dc=com create -subtrees ou=users,dc=example,dc=com -r EXAMPLE.COM -s
-
Start service
sudo service krb5-kdc start
Verify
-
Start container
-
Verify /etc/ldap/slapd.d/cn=config/cn=schema contains cn={5}kerberos.ldif.
-
Run
ldapsearch -L -x -D cn=admin,dc=example,dc=com -b dc=example,dc=com -W
You should see entries for
system:
cn=krbContainer
cn=EXAMPLE.COM,cn=krbContainer
krbPrincipalName=K/[email protected],cn=EXAMPLE.COM,...
krbPrincipalName=krbtgt/EXAMPLE.COM,cn=EXAMPLE.COM,...
people:
krbPrincipalName=kadmin/adminEXAMPLE.COM,cn=EXAMPLE.COM,...
krbPrincipalName=kadmin/[email protected],cn=EXAMPLE.COM,...
krbPrincipalName=kadmin/[email protected],cn=EXAMPLE.COM,...
servers:
krbPrincipalName=kadmin/[email protected],cn=EXAMPLE.COM,...
krbPrincipalName=kiprop/[email protected],cn=EXAMPLE.COM,...
Questions
-
How do I turn on indexing by krbPrincipalName?
-
How do I add the ACL file that restricts access to LDAP entries:
access to dn.base="" by * read access to dn.base="cn=Subschema" by * read access to attrs=userPassword,userPKCS12 by self write by * auth access to attrs=shadowLastChange by self write by * read # Providing access to realm container access to dn.subtree= "cn=EXAMPLE.COM,cn=krbcontainer,dc=example,dc=com" by dn.exact="cn=kdc-service,dc=example,dc=com" write by dn.exact="cn=adm-service,dc=example,dc=com" write by * none # Providing access to principals, if not underneath realm container access to dn.subtree= "ou=users,dc=example,dc=com" by dn.exact="cn=kdc-service,dc=example,dc=com" write by dn.exact="cn=adm-service,dc=example,dc=com" write by * none access to * by * read
Notes
- Some documentation also refers to misc.schema and misc.ldif.
- The cosine.schema at https://github.com/openldap/opendap seems to be a lot bigger than the cosine.schema bundled in the Debian package. Among other things the former one seems to contain some PKI (X.509 certificates) absent from the latter. That's important since we often want LDAP + Kerberos + public key.