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:
auth.yml
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:
auth.yml
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:auth.yml
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:
auth.yml
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:
auth.yml
Role mapping
The last step is to configure role mapping. You must map all roles served by the LDAP directory to the corresponding xorlab roles under theroleMapping: subsection. Roles that are not mapped are ignored by default. Multiple xorlab 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.
auth.yml
roleMappingMode: PASS_THROUGH.
Please be aware that in the pass-through role-mapping mode, all roles served by the LDAP directory are added to the xorlab 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 xorlab.
auth.yml
Activate the configuration
After updatingauth/auth/auth.yml, click Publish. The authentication configuration becomes active within about one minute.
Multi-Tenancy
The setup on this page applies unchanged in a multi-tenant deployment. Two things are added on top: atenant entry in the Attribute mapping that matches the tenant name in guarded_tenants.yml, and a tenant-restricted user role in the Role mapping.
Enable Tenant Login
Complete per-tenant LDAP example, and the other login options available to tenants.
Example configuration
The final configuration for an LDAP backend should look like this:auth.yml