{"id":13144,"date":"2022-06-12T08:16:50","date_gmt":"2022-06-12T05:16:50","guid":{"rendered":"https:\/\/kifarunix.com\/?p=13144"},"modified":"2024-03-09T15:11:25","modified_gmt":"2024-03-09T12:11:25","slug":"integrate-portainer-with-openldap-for-authentication","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/integrate-portainer-with-openldap-for-authentication\/","title":{"rendered":"Integrate Portainer with OpenLDAP for Authentication"},"content":{"rendered":"\n

Follow through this guide to learn how to integrate Portainer with OpenLDAP for authentication. By default, Portainer ships with its own internal authentication mechanism. But if you are using OpenLDAP in your environment, you can easily integrate Portainer with it to make the management of user accounts and access to various container environments easy.<\/p>\n\n\n\n

When using LDAP authentication, Portainer will delegate user authentication to a LDAP server and fallback to internal authentication if LDAP authentication fails.<\/em><\/p>\n\n\n\n

With Portainer community edition, some features are not available.<\/p>\n\n\n\n

Integrate Portainer with OpenLDAP for Authentication<\/h2>\n\n\n\n

To begin with, ensure you have a Portainer and OpenLDAP already installed and setup.<\/p>\n\n\n\n

You can use some of our tutorials below;<\/p>\n\n\n\n

Install Portainer on Linux<\/h3>\n\n\n\n

Install and Setup Portainer in Linux<\/a><\/p>\n\n\n\n

Install OpenLDAP Server on Linux<\/h3>\n\n\n\n

Install and Configure OpenLDAP for Authentication<\/a><\/p>\n\n\n\n

Create OpenLDAP Portainer Access Groups<\/h3>\n\n\n\n

To make the account and access management easy, you can create specific groups on OpenLDAP.<\/p>\n\n\n\n

Each user that needs to access and manage various container environments via the Portainer web interface can belong to a specific OpenLDAP group.<\/p>\n\n\n\n

As per the guide below, we have created two groups, devops<\/code><\/strong> and admins<\/code><\/strong> on OpenLDAP;<\/p>\n\n\n\n

How to Create OpenLDAP Member Groups<\/a><\/p>\n\n\n\n

Confirming the groups and members;<\/p>\n\n\n\n

Devops Group<\/p>\n\n\n\n

ldapsearch -H ldapi:\/\/\/ -Y EXTERNAL -LLL -QQQ \\\n-b \"dc=ldapmaster,dc=kifarunix-demo,dc=com\" cn=devops<\/code><\/pre>\n\n\n\n

Sample output;<\/p>\n\n\n\n

\ndn: cn=devops,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com\nobjectClass: groupOfNames\ncn: devops\nmember: uid=janedoe,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nmember: uid=johndoe,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\n<\/code><\/pre>\n\n\n\n

The individual users have the memberOf attributes defined;<\/p>\n\n\n\n

memberOf: cn=devops,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com<\/code><\/pre>\n\n\n\n

Admins Group;<\/p>\n\n\n\n

ldapsearch -H ldapi:\/\/\/ -Y EXTERNAL -LLL -QQQ \\\n-b \"dc=ldapmaster,dc=kifarunix-demo,dc=com\" cn=admins<\/code><\/pre>\n\n\n\n

Sample output;<\/p>\n\n\n\n

\ndn: cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com\nobjectClass: groupOfNames\ncn: admins\nmember: uid=koromicha,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nmember: uid=linus,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\n<\/code><\/pre>\n\n\n\n

The individual users have the memberOf attributes defined;<\/p>\n\n\n\n

memberOf: cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com<\/code><\/pre>\n\n\n\n
ldapsearch -Y EXTERNAL -H ldapi:\/\/\/ -b \"dc=ldapmaster,dc=kifarunix-demo,dc=com\" uid=* memberOf -QQQ -LLL<\/code><\/pre>\n\n\n\n
dn: uid=johndoe,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nmemberOf: cn=devops,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com\n\ndn: uid=janedoe,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nmemberOf: cn=devops,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com\n\ndn: uid=koromicha,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nmemberOf: cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com\n\ndn: uid=linus,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nmemberOf: cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com\n<\/code><\/pre>\n\n\n\n

Create OpenLDAP Teams Groups on Portainer<\/h3>\n\n\n\n

To make access to various Portainer environments easy, you need to create the exact teams names as the OpenLDAP groups on Portainer.<\/p>\n\n\n\n

In our OpenLDAP, we have two groups, admins and devops.<\/p>\n\n\n\n

Thus, login to Portainer and navigate to Users > Teams<\/strong> and create teams whose names matches<\/strong> the OpenLDAP group names.<\/p>\n\n\n\n

\"Integrate<\/figure><\/div><\/a><\/div>\n\n\n\n

Connect Portainer to OpenLDAP Server<\/h3>\n\n\n\n

Head over to Portainer web interface and navigate to Settings > Authentications > Click LDAP (LDAP Authentication)<\/strong>.<\/p>\n\n\n\n

\"Integrate<\/figure><\/a><\/div>\n\n\n\n

Server type, Custom<\/strong>, is selected by default on the community edition version.<\/p>\n\n\n\n

Next, configure OpenLDAP server connection details;<\/p>\n\n\n\n