LDAP Configuration items
There are some configuration items that configure the ldap realm that should be used. These items can not be changed with the Account Management in JOC.
Key | Value | Description |
---|---|---|
ldapReam | com.sos.auth.shiro.SOSLdapAuthorizingRealm | The key is the name of the realm. You can define any name. The name is taken as a reference to set the properties of the realm. The value is the name of the class that implements the realm. The implementation from SOS extends |
ldapRealm.contextFactory.url | ldap://host:port | The host and the port of your LDAP server. You can check whether the server is reachable with Make sure that the firewall is open for the given port. |
ldapRealm.useStartTls | true|false | To enable starttls set the value to true (Default is Please note the the server must be prepared to serve with Starttls. To check this, you can use a LDAP browser like "Softerra LDAP Browser". Configure your LDAP Server there and click the "Enable Starttls Button" On Client Site you will need the certificate and you have to add the certificate to your truststore. The path of your truststore is definied in the JOC configuration file joc.properties.
e.g.
|
ldapRealm.hostNameVerification | on|off true|false | To enable the host name verification of the certificate. The default is off. |
rolePermissionResolver | com.sos.auth.shiro.SOSPermissionResolverAdapter | The implementation of the permission resolver. The SOS implementation sets an org.apache.shiro.realm.text.IniRealm to resolve the permissions. That means that the permissions a role have are specified in the configuration file shiro.ini in the same way it is done when using the iniRealm . |
ldapRealm.rolePermissionResolver | $rolePermissionResolver | Sets the role permission resolver for the ldap realm. |
securityManager.realms | $ldapRealm | Sets the list of realm that should be used for authentication. This is a comma seperated list of realms. e.g.
|
[main] ... ldapRealm = com.sos.auth.shiro.SOSLdapAuthorizingRealm ldapRealm.contextFactory.url = ldap://myHost:389 ldapRealm.useStartTls = true ldapRealm.hostNameVerification = off rolePermissionResolver = com.sos.auth.shiro.SOSPermissionResolverAdapter rolePermissionResolver.ini = $iniRealm ldapRealm.rolePermissionResolver = $rolePermissionResolver securityManager.realms = $ldapRealm ...
Authentication
Authorization
Assigning roles from shiro.ini
Assiging roles from LDAP Groups
The group roles mapping
Identifying the group of the user
Using member of with User Search
Using group search
Using more than one LDAP server
LDAP Authentication
Please note that:
- Roles for users that are authenticated via LDAP can be specified in the
[users]
section of theshiro.ini
without a password.- The syntax is then:
- username = , role1, role2
- LDAP account names can include blank spaces. FEATURE AVAILABILITY STARTING FROM RELEASE 1.11.5
This syntax applies whether or not password hashing (see above) is active.
- The syntax is then:
- The
[users]
section can be deleted if roles from theshiro.ini
are not to be used at all.
The [main]
section contains the following information:
- specification of the LDAP directory service,
- a mapping of the JOC Cockpit role names specified in the
[roles]
section of the file onto LDAP group names and - a session timeout.
Getting the roles for a user account
You have to specify:
ldapRealm.userDnTemplate = cn={0},CN=mycn,DC=localhost ldapRealm.searchBase = CN=mycn,DC=localhost ldapRealm.contextFactory.url = ldap://localhost:389 #ldapRealm.groupNameAttribute=memberOf #ldapRealm.userNameAttribute=cn ldapRealm.groupRolesMap = \ "CN=??????,OU=?????,OU=?????,OU=?????,DC=domain,DC=local":"all" ldapRealm.userSearchFilter=(&(objectClass=User)(cn=%s))+
%s will be substituted by the user account.
To get the correct values for ldapRealm.userDnTemplate, ldapRealm.searchBase and ldapRealm.userSearchFilter
- please create a query that finds all groups the user account is a member of
- set ldapRealm.userSearchFilter to this query with %s for the user name.
- Example:
(&(objectClass=User)(cn=%s))
- Example:
(uniqueMember=uid=%s,dc=example,dc=com)
- Example:
- set ldapRealm.userSearchFilter to this query with %s for the user name.
- Then identify the attribute in the result that contains the groupName
- set ldapReal.groupNameAttribute to this value (default is memberOf)
- Then assign the value of attribute specified in groupNameAttribute to the groupRolesMap
- Example:
ldapRealm.groupRolesMap="value in attribute groupNameAttribute":"it_operator
- Example:
- The userDnTemplate is identifiying the user entry in LDAP (e.g. the value of uniqueMember)
Simple Example LDAP Configuration
An example for LDAP configuration is provided with the listing below:
Example of an Active Directory (AD) LDAP Configuration
It should only be necessary for system administrators to modify three parts of this section:
- the LDAP directory service information in lines 4 to 6 of the listing,
- the mapping of LDAP groups to roles - here occupying lines 13 to 16 and which is described in the next sub-section and
- the timeout setting for sessions as shown in the last line of the listing and which is specified in milliseconds.
Example Mapping LDAP Groups to Roles:
- In line 15 of the first listing above members of the JobScheduler_it_operator LDAP group are assigned the it_operator role
- More than one role can be specified for members of an LDAP group - for example:
- in line 16 of the first listing members of the LDAP jobscheduler_admin group are assigned the roles of administrator and application_manager.
Example LDAP Configuration with a public LDAP Server
There are many ways of configuring LDAP authentication and authorization. The method you use depends on the structure of groups and users in your LDAP Server. You will find a working example for use with a public LDAP Server described on:
We cannot guarantee that the public LDAP Server will always be online, however, if you struggle with LDAP configuration then you might want to give it a try to have a working example.
To use this example:
- Make a backup of your current shiro.ini file and then copy the contents of the example code block into your shiro.ini file.
- Restart your web services server.
- Log into the JOC Cockpit using the "gauss" account name and the password "password".
Example LDAP Configuration with a public LDAP Server and mixed LDAP and Shiro Authentication
The following code block is a copy of the short example above showing the authentication of a single LDAP user account, gauss, and an additional Shiro-authenticated administrator user account.
- The Shiro-authenticated user account has been added to the [users] section as normal.
- Note that line 21 of the listing has been modified to read:
securityManager.realms = $ldapRealm, $iniRealm
Example LDAP Configuration with Several LDAP Servers
LDAP configuration with several LDAP servers is achieved by defining more than one LDAP realm as shown in the next code block.
Assigning roles in the shiro.ini when using LDAP
It is possible to mix LDAP authentication with local authorization from a shiro.ini file.
- In the
[users]
section- specify the user name but do not specify a password for the user.
- specify the list of roles that are assigned to this user.
- Important: The assignment must start with a comma to skip the password assignment.
- In the
[main]
section- you do not have to specify the LDAP group mapping to roles.
Both the roles specified with the user assignment and the roles retrieved from the ldapRealm.groupRolesMap mapping will be added to the user.
[users]
assignments are optional.