Sync LDAP JWT Users
On this page
The Lightweight Directory Access Protocol (LDAP) sync feature of the Operator ensures that LDAP users are synced with SingleStore using the JSON Web Token (JWT) authentication type.
Prerequisites
-
An LDAP server, which is necessary to provide directory services.
The community OpenLDAP Docker container is reflected in these instructions, which can be installed via the following command. docker run -p 389:389 -p 636:636 --name my-openldap-container --detach osixia/openldap:1.4.0 -
A Kubernetes cluster with the application endpoints exposed and services accessible to the LDAP server and Storage classes.
-
The associated tools are installed and running, including:
-
The SingleStore Tools container for use with the Operator
-
A SQL client, such as the SingleStore client
-
The
ldap-
utils package -
curl
-
kubectl
Check Connectivity
-
Check connectivity to SingleStore.
singlestore -h 172.26.0.2 -u admin -P 3306 -p<password> -e 'SHOWUSERS'+------------+--------+-------------+------------+-----------------------+----------+ | User | Type | Connections | Is deleted | Default resource pool | Is local | +------------+--------+-------------+------------+-----------------------+----------+ | admin'@'%' | Native | 1 | | | SYNC | | 'root'@'&' | Native | 0 | | | LOCAL | +------------+--------+-------------+------------+-----------------------+----------+
-
Check connectivity to the LDAP server.
./bin/singlestoredb-toolbox-1.16.0-c63e2fe53f/sdb-admin sync-ldap \--uris ldap://localhost \--groups engineers \--search-base dc=example,dc=or \--schema open-ldap \--auth-method JWT \--show-detail \--bind-user cn=admin,dc=example,dc=org \--bind-credentials admin \--user admin \--password mypassword \--host 172.26.0.2 -y✔ Successfully prepared the sync LDAP users and groups are already synced
Sync an LDAP User
-
Add a user to the LDAP server.
ldapadd -x -H ldap://localhost -D "cn=admin,dc=example,dc=org" -w admin -f user.ldifadding new entry "uid-peter,de-example,de=org"
cat user.ldifdn: uid=peter,dc=example,dc=org objectClass: top objectClass: account objectClass: posixAccount objectClass: shadowAccount cn: peter uid: peter uidNumber: 16859 gidNumber: 100 homeDirectory: /home/peter loginShell: /bin/bash gecos: peter userPassword: {crypt}x shadowLastChange: 0 shadowMax: 0 shadowWarning: 0
-
Create a new group.
ldapadd -x -H ldap://localhost -D "cn=admin,de=example,dc=org" -w admin -f group.Idifadding new entry "cn=engineers,dc=example,dc=org"
cat group.ldifdn: cn=engineers,dc=example,dc=org objectClass: top objectClass: posixGroup gidNumber: 678
-
Assign this user to this group.
ldapmodify -x -H ldap://localhost -D "cn=admin,dc=example,dc=org" -w admin -f add.ldifmodifying entry "cn=engineers,dc=example,dc=org"
cat add.ldifdn: cn=engineers,dc=example,dc=org changetype: modify add: memberuid memberuid: peter
-
Add the LDAP user as a JWT user to SingleStore.
./bin/singlestoredb-toolbox-1.16.0-c63e2fe53f/sdb-admin sync-ldap \--uris ldap://localhost \--groups engineers \--search-base dc=example,dc=org \--schema open-ldap \--auth-method JWT \--show-detail \--bind-user cn=admin,dc=example,dc=org \--bind-credentials admin \--user admin \--password mypassword \--host 172.26.0.2 -y✔ Successfully prepared the sync Toolbox is about to sync 'engineers' by performing the following actions: • Create the following users: -peter • Create the following groups: - engineers • Grant the following groups to users: - To user 'peter': + engineers + ldap_users_internal_group Would you like to continue?[Y/n]: Automatically selected yes, non-interactive mode enabled Toolbox synced 'engineers' with the following results: • Created 1 user out of 1 • Created 1 group out of 1 • Granted 2 groups out of 2
-
Confirm that the LDAP user is now reflected as a JWT user in SingleStore.
singlestore -h 172.26.0.2 -u admin -P 3306 -pmypassword -e 'SHOWUSERS'+------------+--------+-------------+------------+-----------------------+----------+ | User | Type | Connections | Is deleted | Default resource pool | Is local | +------------+--------+-------------+------------+-----------------------+----------+ | admin'@'%' | Native | 1 | | | SYNC | | peter'@'%' | JWT | 0 | | | SYNC | | 'root'@'&' | Native | 0 | | | LOCAL | +------------+--------+-------------+------------+-----------------------+----------+
Last modified: October 24, 2023