LDAP Authentication/ACL

LDAP authentication/access control uses an external OpenLDAP server as the authentication data source, which can store large amounts of data and facilitate integration with external device management systems.

Create module

Open EMQX DashboardLDAP AUTH/ACL - 图1 (opens new window), click the “Modules” tab on the left, and choose to add:

image-20200928161310952

Select LDAP authentication/access control module

image-20200928144927769

Configure OpenLDAP related parameters

image-20200928144945076

Finally, click the “Add” button, the module can be added successfully:

image-20200928145033628

LDAP Schema

The data model needs to be configured in the LDAP schema directory. The data model in the default configuration is as follows:

/etc/openldap/schema/emqx.schema

  1. attributetype (1.3.6.1.4.1.11.2.53.2.2.3.1.2.3.1.3 NAME'isEnabled'
  2. EQUALITY booleanMatch
  3. SYNTAX 1.3.6.1.4.1.1466.115.121.1.7
  4. SINGLE-VALUE
  5. USAGE userApplications)
  6. attributetype (1.3.6.1.4.1.11.2.53.2.2.3.1.2.3.4.1 NAME ('mqttPublishTopic''mpt')
  7. EQUALITY caseIgnoreMatch
  8. SUBSTR caseIgnoreSubstringsMatch
  9. SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
  10. USAGE userApplications)
  11. attributetype (1.3.6.1.4.1.11.2.53.2.2.3.1.2.3.4.2 NAME ('mqttSubscriptionTopic''mst')
  12. EQUALITY caseIgnoreMatch
  13. SUBSTR caseIgnoreSubstringsMatch
  14. SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
  15. USAGE userApplications)
  16. attributetype (1.3.6.1.4.1.11.2.53.2.2.3.1.2.3.4.3 NAME ('mqttPubSubTopic''mpst')
  17. EQUALITY caseIgnoreMatch
  18. SUBSTR caseIgnoreSubstringsMatch
  19. SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
  20. USAGE userApplications)
  21. objectclass (1.3.6.1.4.1.11.2.53.2.2.3.1.2.3.4 NAME'mqttUser'
  22. AUXILIARY
  23. MAY (mqttPublishTopic $ mqttSubscriptionTopic $ mqttPubSubTopic))
  24. objectclass (1.3.6.1.4.1.11.2.53.2.2.3.1.2.3.2 NAME'mqttDevice'
  25. SUP top
  26. STRUCTURAL
  27. MUST (uid)
  28. MAY (isEnabled))
  29. objectclass (1.3.6.1.4.1.11.2.53.2.2.3.1.2.3.3 NAME'mqttSecurity'
  30. SUP top
  31. AUXILIARY
  32. MAY (userPassword $ userPKCS12 $ pwdAttribute $ pwdLockout))

Edit the ldap configuration file slapd.conf to reference the Schema:

/etc/openldap/slapd.conf

  1. include /etc/openldap/schema/core.schema
  2. include /etc/openldap/schema/cosine.schema
  3. include /etc/openldap/schema/inetorgperson.schema
  4. include /etc/openldap/schema/ppolicy.schema
  5. include /etc/openldap/schema/emqx.schema
  6. database bdb
  7. suffix "dc=emqx,dc=io"
  8. rootdn "cn=root,dc=emqx,dc=io"
  9. rootpw {SSHA}eoF7NhNrejVYYyGHqnt+MdKNBh4r1w3W
  10. directory /etc/openldap/data

The sample data in the default configuration is as follows:

  1. ## create emqx.io
  2. dn:dc=emqx,dc=io
  3. objectclass: top
  4. objectclass: dcobject
  5. objectclass: organization
  6. dc:emqx
  7. o: emqx, Inc.
  8. # create testdevice.emqx.io
  9. dn:ou=testdevice,dc=emqx,dc=io
  10. objectClass: top
  11. objectclass:organizationalUnit
  12. ou:testdevice
  13. dn:uid=mqttuser0001,ou=testdevice,dc=emqx,dc=io
  14. objectClass: top
  15. objectClass: mqttUser
  16. objectClass: mqttDevice
  17. objectClass: mqttSecurity
  18. uid: mqttuser0001
  19. isEnabled: TRUE
  20. mqttAccountName: user1
  21. mqttPublishTopic: mqttuser0001/pub/1
  22. mqttSubscriptionTopic: mqttuser0001/sub/1
  23. mqttPubSubTopic: mqttuser0001/pubsub/1
  24. userPassword:: e1NIQX1tbGIzZmF0NDBNS0JUWFVWWndDS21MNzNSLzA9

After enabling LDAP authentication, you can connect via username: mqttuser0001 and password: public.

LDAP access control configuration method

mqttPublishTopic allowed topics to be published (multiple can be configured)

mqttSubscriptionTopic allows to subscribe to the topic (multiple can be configured)

mqttPubSubTopic allows to subscribe/publish the topic (multiple can be configured)

TIP

The current version only supports OpenLDAP, not Microsoft Active Directory.