Before you start configuring this backend, please read the Authentication article, if you haven’t already.
Basic configuration
LDAP backend is defined in theldapAuthDataSources: 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:
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 theauthentication: subsection of your LDAP server configuration.
Direct DN
If you want to use a direct DN of a user, you just set thewithUserDn.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:Authorization
After a successful authentication, a user has to be authorized: their roles are read from the LDAP backend. In theauthorization.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:
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 theattributeMapping: subsection.
You can use these methods:
attr('<name>'): retrieve the attribute with the'<name>'name from attributes in the source authorization systemreplace(<string or list of strings>, '<pattern>', 'replace'): replace every occurrence of'<pattern>'with'replace'in an input string or a list of input stringsazureAdEmails(): read all email addresses from the Azure Active DirectoryproxyAddressesattribute.
key: 'literal value'.
A sample configuration for attribute mapping, which simply retrieves attributes from the auth system, would look like this:
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 theroleMapping: subsection. Roles that are not mapped are ignored by default. Multiple XSP roles can be mapped to the same LDAP role, e.g., xcc_login → company1-group1, xcc_admin → company1-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.
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.
Multi-Tenant Configuration
Please follow the instructions on this page to setup LDAP-based Authentication in a multi-tenancy deployment. Make to include thetenant 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.