jp-gouin / helm-openldap

Helm chart of Openldap in High availability with multi-master replication and PhpLdapAdmin and Ltb-Passwd
Apache License 2.0
183 stars 115 forks source link

add customSchemaFiles option #98

Closed wkloucek closed 1 year ago

wkloucek commented 1 year ago

What this PR does / why we need it:

Solves following feature request from the Readme:

- Replication is now purely setup by configuration. Extra schemas are loaded using `LDAP_EXTRA_SCHEMAS: "cosine,inetorgperson,nis,syncprov,serverid,csyncprov,rep,bsyncprov,brep,acls".
  - For now this list is harcoded and will be configurable in a future update.
  - (let me know if you need this feature priorityzed)

It now allows you to set custom schemas in customSchemaFiles like you can do with customLdifFiles for LDIF files. Sadly I found no way to support a customSchemaCm analogous to customLdifCm (because of the subPath mount logic in statefulset.yaml).

Pre-submission checklist:

jp-gouin commented 1 year ago

Thanks you @wkloucek for this PR ! Do you have an example of a simple schema that I can use to verify the PR ?

wkloucek commented 1 year ago

Thanks you @wkloucek for this PR ! Do you have an example of a simple schema that I can use to verify the PR ?

I personally use it with a custom schema for my ownCloud Infinite Scale installation (schema from here https://github.com/owncloud/ocis/blob/master/deployments/examples/ocis_ldap/config/ldap/ldif/10_owncloud_schema.ldif):

values.yaml

global:
  ldapDomain: dc=owncloud,dc=com

customSchemaFiles:
  10_owncloud_schema.ldif: |-
    # This LDIF files describes the ownCloud schema and can be used to
    # add two optional attributes: ownCloudQuota and ownCloudUUID
    # The ownCloudUUID is used to store a unique, non-reassignable, persistent identifier for users and groups
    dn: cn=owncloud,cn=schema,cn=config
    objectClass: olcSchemaConfig
    cn: owncloud
    olcObjectIdentifier: ownCloudOid 1.3.6.1.4.1.39430
    olcAttributeTypes: ( ownCloudOid:1.1.1 NAME 'ownCloudQuota'
      DESC 'User Quota (e.g. 2 GB)'
      EQUALITY caseExactMatch
      SUBSTR caseIgnoreSubstringsMatch
      SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
    olcAttributeTypes: ( ownCloudOid:1.1.2 NAME 'ownCloudUUID'
      DESC 'A non-reassignable and persistent account ID)'
      EQUALITY uuidMatch
      SUBSTR caseIgnoreSubstringsMatch
      SYNTAX 1.3.6.1.1.16.1 SINGLE-VALUE )
    olcObjectClasses: ( ownCloudOid:1.2.1 NAME 'ownCloud'
      DESC 'ownCloud LDAP Schema'
      AUXILIARY
      MAY ( ownCloudQuota $ ownCloudUUID ) )

customLdifFiles:
  base.ldif: |-
    dn: dc=owncloud,dc=com
    objectClass: organization
    objectClass: dcObject
    dc: owncloud
    o: ownCloud

    dn: ou=users,dc=owncloud,dc=com
    objectClass: organizationalUnit
    ou: users

    dn: ou=groups,dc=owncloud,dc=com
    objectClass: organizationalUnit
    ou: groups

    dn: uid=einstein,ou=users,dc=owncloud,dc=com
    objectClass: inetOrgPerson
    objectClass: organizationalPerson
    objectClass: ownCloud
    objectClass: person
    objectClass: posixAccount
    objectClass: top
    uid: einstein
    givenName: Albert
    sn: Einstein
    cn: einstein
    displayName: Albert Einstein
    description: A German-born theoretical physicist who developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics).
    mail: einstein@example.org
    uidNumber: 20000
    gidNumber: 30000
    homeDirectory: /home/einstein
    ownCloudUUID:: NGM1MTBhZGEtYzg2Yi00ODE1LTg4MjAtNDJjZGY4MmMzZDUx
    userPassword:: e1NTSEF9TXJEcXpFNGdKbXZxbVRVTGhvWEZ1VzJBbkV3NWFLK3J3WTIvbHc9PQ==

The startup log says:

...
63f32fa9.015ec377 0x7fc0c37fe700 conn=1012 op=1 ADD dn="cn=owncloud,cn=schema,cn=config"
63f32fa9.016a9819 0x7fc0c37fe700 conn=1012 op=1 RESULT tag=105 err=0 qtime=0.000018 etime=0.000855 text=
63f32fa9.016d756f 0x7fc0c8dfe700 conn=1012 op=2 UNBIND
adding new entry "cn=owncloud,cn=schema,cn=config"

63f32fa9.016edfb7 0x7fc0c8dfe700 conn=1012 fd=12 closed
 08:30:33.06 INFO  ==> Loading custom LDIF files...
 08:30:33.06 WARN  ==> Ignoring LDAP_USERS, LDAP_PASSWORDS, LDAP_USER_DC and LDAP_GROUP environment variables...
63f32fa9.050911b5 0x7fc0c3fff700 conn=1013 fd=12 ACCEPT from PATH=/opt/bitnami/openldap/var/run/ldapi (PATH=/opt/bitnami/openldap/var/run/ldapi)
63f32fa9.050b064c 0x7fc0c37fe700 conn=1013 op=0 BIND dn="cn=admin,dc=owncloud,dc=com" method=128
63f32fa9.050c255d 0x7fc0c37fe700 conn=1013 op=0 BIND dn="cn=admin,dc=owncloud,dc=com" mech=SIMPLE bind_ssf=0 ssf=71
63f32fa9.050cf88a 0x7fc0c37fe700 conn=1013 op=0 RESULT tag=97 err=0 qtime=0.000032 etime=0.000200 text=
63f32fa9.0510f464 0x7fc0c8dfe700 conn=1013 op=1 ADD dn="dc=owncloud,dc=com"
63f32fa9.0581fdac 0x7fc0c8dfe700 conn=1013 op=1 RESULT tag=105 err=0 qtime=0.000021 etime=0.007445 text=
63f32fa9.058638c4 0x7fc0c3fff700 conn=1013 op=2 ADD dn="ou=users,dc=owncloud,dc=com"
63f32fa9.05ec2d7e 0x7fc0c3fff700 conn=1013 op=2 RESULT tag=105 err=0 qtime=0.000049 etime=0.006770 text=
63f32fa9.05ff3f30 0x7fc0c37fe700 conn=1013 op=3 ADD dn="ou=groups,dc=owncloud,dc=com"
63f32fa9.06474977 0x7fc0c37fe700 conn=1013 op=3 RESULT tag=105 err=0 qtime=0.000044 etime=0.004795 text=
63f32fa9.064b976c 0x7fc0c8dfe700 conn=1013 op=4 ADD dn="uid=einstein,ou=users,dc=owncloud,dc=com"
63f32fa9.06a300c5 0x7fc0c8dfe700 conn=1013 op=4 RESULT tag=105 err=0 qtime=0.000017 etime=0.005778 text=
adding new entry "dc=owncloud,dc=com"

adding new entry "ou=users,dc=owncloud,dc=com"

adding new entry "ou=groups,dc=owncloud,dc=com"

adding new entry "uid=einstein,ou=users,dc=owncloud,dc=com"

63f32fa9.06a6b926 0x7fc0c3fff700 conn=1013 op=5 UNBIND
63f32fa9.06a87dcc 0x7fc0c3fff700 conn=1013 fd=12 closed
63f32fa9.0741d417 0x7fc0c95ff700 daemon: shutdown requested and initiated.
63f32fa9.07469b36 0x7fc0c95ff700 slapd shutdown: waiting for 0 operations/tasks to finish
63f32fa9.07a8d86c 0x7fc0ca760740 slapd stopped.
 08:30:34.14 INFO  ==> ** LDAP setup finished! **

LDAP search ldapsearch -x -H ldap://ldap.ldap.svc.cluster.local:389 -x -D $LDAP_USER -w $LDAP_PASS -b ou=users,dc=owncloud,dc=com returns:

# extended LDIF
#
# LDAPv3
# base <ou=users,dc=owncloud,dc=com> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# users, owncloud.com
dn: ou=users,dc=owncloud,dc=com
objectClass: organizationalUnit
ou: users

# einstein, users, owncloud.com
dn: uid=einstein,ou=users,dc=owncloud,dc=com
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: ownCloud
objectClass: person
objectClass: posixAccount
objectClass: top
uid: einstein
givenName: Albert
sn: Einstein
cn: einstein
displayName: Albert Einstein
description: A German-born theoretical physicist who developed the theory of r
 elativity, one of the two pillars of modern physics (alongside quantum mechan
 ics).
mail: einstein@example.org
uidNumber: 20000
gidNumber: 30000
homeDirectory: /home/einstein
ownCloudUUID: 4c510ada-c86b-4815-8820-42cdf82c3d51
userPassword:: e1NTSEF9TXJEcXpFNGdKbXZxbVRVTGhvWEZ1VzJBbkV3NWFLK3J3WTIvbHc9PQ=
 =

# search result
search: 2
result: 0 Success

# numResponses: 3
# numEntries: 2