Skip to main content
xorlab Authentication Service needs search and read access through the LDAP interface to verify user credentials. The connection to an LDAP server requires a custom certificate in a trust store.
Before you start configuring this backend, please read the Authentication article, if you haven’t already.

Basic configuration

LDAP backend is defined in the ldapAuthDataSources: subsection of the usernamePasswordAuthBackends: section in the auth/auth/auth.yml file. First, you have to set up the basic parameters of your LDAP source, starting with its name—that can be whatever you like (myLDAP in this sample case)—and then configuring the connection as in the example below:
The following table explains the parameters:

Authentication

The next step involves user authentication in your LDAP server. You can use a direct distinguished name (DN) of a user who is being authenticated (if you already know what the DN of a user looks like) or query LDAP for the DN. Either way, you have to specify only one method. This is done within the authentication: subsection of your LDAP server configuration.

Direct DN

If you want to use a direct DN of a user, you just set the withUserDn.userDnPattern attribute to a pattern which will allow to deduct a DN from a login username string, e.g., "uid={0},ou=users,dc=company,dc=com", where {0} will be substituted with a username:

DN query

When a DN of a user is not known, you can search the LDAP directory for the user entry using a so-called technical user for authentication. Once the user entry is found, their DN is used to authenticate with the provided credentials. A sample configuration of a DN query is as follows:
The table below explains the parameters:

Authorization

After a successful authentication, a user has to be authorized: their roles are read from the LDAP backend. In the authorization.query: subsection, you can configure the parameters of the role search using a nested search within a subtree of a directory as in the sample configuration below:
The parameters are explained in the table below:

Attribute mapping

In the next step you have to map (assign) attributes from the LDAP user entries to the user model in xorlab Security Platform. The mapping is described using Spring expression language and is configured under the attributeMapping: subsection. You can use these methods:
  • attr('<name>'): retrieve the attribute with the '<name>' name from attributes in the source authorization system
  • replace(<string or list of strings>, '<pattern>', 'replace'): replace every occurrence of '<pattern>' with 'replace' in an input string or a list of input strings
  • azureAdEmails(): read all email addresses from the Azure Active Directory proxyAddresses attribute.
Literal values have to be quoted, e.g., key: 'literal value'. A sample configuration for attribute mapping, which simply retrieves attributes from the auth system, would look like this:
Available attributes are explained in the table below:

Role mapping

The last step is to configure role mapping. You must map all roles served by the LDAP directory to the corresponding XSP roles under the roleMapping: subsection. Roles that are not mapped are ignored by default. Multiple XSP roles can be mapped to the same LDAP role, e.g., xcc_logincompany1-group1, xcc_admincompany1-group1.
The role mapping is case sensitive, therefore make sure that you specify the role names according to what is served by the LDAP directory.
A sample role mapping configuration is shown below:
If the LDAP directory already serves roles compatible with xorlab Security Platform (see Users, Roles, and Permissions), you can also specify a “pass-through” role-mapping mode using roleMappingMode: PASS_THROUGH (note that this was the default behavior before XSP 7.0).
Please be aware that in the pass-through role-mapping mode, all roles served by the LDAP directory are added to the XSP authorization context. If this context is becoming too large, i.e., too many irrelevant roles are added, then it might lead to errors and users being unable to access XCC. Therefore, it is advisable to only map the roles that are relevant to XSP.
A sample role mapping configuration using the pass-through mode:

Multi-Tenant Configuration

Please follow the instructions on this page to setup LDAP-based Authentication in a multi-tenancy deployment. Make to include the tenant property in the Attribute Mapping configuration and that its value is a one-on-one match with the authTenantId property specified in the Multi-Tenancy Configuration. For roleMapping, make sure to map to a tenant-restricted user roles.

Example configuration

The final configuration for an LDAP backend should look like this: