This documentation is available to agents as Markdown at https://docs.synthesized.io/tdk/latest/user_guide/060_security_compliance/authentication/ldap_activedirectory.md. For the complete documentation index, see llms.txt.

LDAP and Active Directory

Users can sign in to Governor with their directory account. Governor checks the user name and password against your LDAP server or Active Directory, and can take each user’s role from their directory groups.

The integration is based on the spring-security-ldap module.

Before you start

  • You need access to your organization’s LDAP server, and a test account. To try the integration locally, you can run an LDAP server with ldap-sdk-tools.

  • Use ldaps://, so passwords travel encrypted. Governor’s JVM must trust the certificate authority that signed the LDAP server’s certificate.

  • The settings on this page are Spring properties of Governor’s API. On Docker Compose, set them as environment variables on the backend service, as described in Single Sign-On.

  • Unless roles come from LDAP groups, the first user who signs in becomes an ADMINISTRATOR. Sign in as the intended administrator first.

In the examples, CN is a common name, OU an organizational unit and DC a domain component.

Connect to the server

Set the server’s URL with spring.ldap.urls, for example ldaps://ldap.example.com:636. To use several servers, list their URLs, separated by commas. Plain LDAP uses ldap:// and usually port 389.

spring.ldap.urls=ldaps://ldap.example.com:636
spring.ldap.base=dc=synthesized,dc=io

spring.ldap.base is the root of all LDAP operations: the distinguished names in the other settings are relative to it.

Find users

Tell Governor where users are and how to match the name they sign in with. For a user defined like this:

dn: uid=bob,ou=people,dc=synthesized,dc=io
objectclass: top
objectclass: person
objectclass: organizationalPerson
objectclass: inetOrgPerson
cn: Bob Hamilton
sn: Hamilton
uid: bob
userPassword: bobspassword

set:

ldap.user-details.user-search-base=ou=people (1)
ldap.user-details.user-search-filter=uid={0} (2)
1 Where users are: here, the people unit.
2 How to match the sign-in name: here, against uid. {0} is the name the user typed.

These values are the defaults, so you only need them if your directory is organized differently.

Check passwords

Governor reads the stored password from the user’s userPassword attribute and compares it with the one the user typed. It detects these password formats: SHA, SHA256, SHA384, SHA512, SSHA, SSHA256, SSHA384, SSHA512, MD5, SMD5, PKCS5S2, CRYPT and plain text.

So the account Governor connects with must be able to read userPassword, as well as users and groups. Set it with:

spring.ldap.username=cn=governor,ou=services,dc=synthesized,dc=io (1)
spring.ldap.password=<password> (2)
1 The distinguished name of the account Governor connects with. Without it, Governor connects anonymously.
2 That account’s password.

Limit this account to reading users, groups and userPassword, and use ldaps://, so the stored passwords travel encrypted.

A directory that lets no account read passwords can’t be used with LDAP sign-in. For Active Directory, use the Active Directory provider, which doesn’t read passwords.

Roles from LDAP groups

Directory groups map to the global roles MEMBER and ADMINISTRATOR. OWNER is an older name for ADMINISTRATOR: mappings that still use it keep working, but use ADMINISTRATOR in new ones. See Roles and Permissions. Roles come from one of two places.

Roles managed in Governor (default)

Administrators manage roles in Governor. The first user who signs in gets the ADMINISTRATOR role, and later users get MEMBER.

Roles from the directory

Governor reads the user’s groups from the directory at each sign-in. For groups like this one:

dn: cn=administrator,ou=groups,dc=synthesized,dc=io
objectclass: top
objectclass: groupOfUniqueNames
cn: administrator
uniqueMember: uid=bob,ou=people,dc=synthesized,dc=io

turn it on with:

ldap.authorities.enabled=true

To change how groups are found, set these. The values shown are the defaults:

ldap.authorities.group-search-base=ou=groups (1)
ldap.authorities.group-role-attribute=cn (2)
ldap.authorities.group-user-search-filter=(uniquemember={0}) (3)
ldap.authorities.ignore-partial-result-exception=false (4)
ldap.authorities.convert-to-uppercase=true (5)
ldap.authorities.default-role=MEMBER (6)
1 Where groups are. Governor searches this unit only, not the units below it.
2 The attribute of a group that holds its name.
3 How to find the groups a user belongs to. {0} is the user’s distinguished name, and {1} the name they signed in with.
4 true ignores PartialResultException in searches, which avoids some issues with Active Directory. See LdapTemplate.
5 Converts group names to upper case before they’re matched, so matching ignores case.
6 The role for a user whose groups match no role.

A group named after a role gets that role: while convert-to-uppercase is on, in any case, such as administrator. Map other group names to roles with aliases:

ldap.authorities.role-aliases.tdk-admins=ADMINISTRATOR
ldap.authorities.role-aliases.developers=MEMBER

The role-aliases map can’t be set with environment variables. On Docker Compose, and anywhere the API is set up through its environment, use the numbered list instead:

LDAP_AUTHORITIES_ALIASES_0_GROUP=tdk-admins
LDAP_AUTHORITIES_ALIASES_0_ROLE=ADMINISTRATOR
LDAP_AUTHORITIES_ALIASES_1_GROUP=developers
LDAP_AUTHORITIES_ALIASES_1_ROLE=MEMBER

You can use both forms together: they’re merged at startup.

  • A user’s groups must all map to the same role. A user in groups that map to different roles can’t sign in.

  • Roles are updated at each sign-in from the user’s current groups, and role management in the web UI becomes read-only.

Admitting only members of mapped groups

By default, a user whose groups match no role still signs in, with default-role. To turn away anyone outside a mapped group:

ldap.authorities.require-mapped-authority=true

It only takes effect with ldap.authorities.enabled=true; with roles managed in Governor, it does nothing. When it takes effect, default-role is ignored. A user outside every mapped group who enters the right password stays on the sign-in page, with a message that their account isn’t in an approved group, and Governor creates no account for them. A wrong password gets the usual message, so the setting doesn’t reveal who has an account.

Active Directory

Governor has a provider for Active Directory’s conventions. It signs users in with their User-Principal-Name, and checks the password by signing in to Active Directory as the user, so no password is read from the directory.

activedirectory.urls=ldaps://ad.example.com:636 (1)
activedirectory.domain=synthesized.io (2)
activedirectory.root-dn=dc=synthesized,dc=io (3)
1 The server URL, or several URLs.
2 The domain name. Can be empty.
3 The root distinguished name. Can be empty: then the domain is used, and if both are empty, searches start from the root.

Roles from Active Directory groups

By default, roles are managed in Governor, as described in Roles managed in Governor (default). To take them from the groups the user belongs to, turn on the mapping and map group names to roles:

activedirectory.authorities.enabled=true
activedirectory.authorities.role-aliases.tdk-admins=ADMINISTRATOR
activedirectory.authorities.role-aliases.developers=MEMBER
activedirectory.authorities.default-role=MEMBER (1)
1 The role for a user in no group that maps to a role. Default: MEMBER.

On Docker Compose, and anywhere the API is set up through its environment, use the numbered list:

ACTIVEDIRECTORY_AUTHORITIES_ENABLED=true
ACTIVEDIRECTORY_AUTHORITIES_ALIASES_0_GROUP=tdk-admins
ACTIVEDIRECTORY_AUTHORITIES_ALIASES_0_ROLE=ADMINISTRATOR
ACTIVEDIRECTORY_AUTHORITIES_ALIASES_1_GROUP=developers
ACTIVEDIRECTORY_AUTHORITIES_ALIASES_1_ROLE=MEMBER
  • Governor uses the name of each group listed in the user’s memberOf attribute: the groups the user belongs to directly, not groups nested inside them.

  • While activedirectory.authorities.convert-to-uppercase is true, the default, group names are matched case-insensitively, and a group named after a role, such as administrator, gets that role without an alias.

  • A user in several mapped groups gets the highest role: ADMINISTRATOR before MEMBER.

  • Roles are updated at each sign-in from the user’s current groups, and role management in the web UI becomes read-only.

  • The group search settings of Roles from the directory don’t apply to Active Directory.

To turn away users outside every mapped group, set activedirectory.authorities.require-mapped-authority=true (ACTIVEDIRECTORY_AUTHORITIES_REQUIREMAPPEDAUTHORITY=true). It works as described in Admitting only members of mapped groups, and likewise only with activedirectory.authorities.enabled=true.

Check that it works

  1. Sign in with a directory account in a private browser window.

  2. Under Administration, check that the user has the role you expect.

  3. With roles from the directory, sign in as a member of each mapped group.

  4. With require-mapped-authority on, sign in as a user outside every mapped group, and check that they’re refused.

LDAP uses Governor’s email and password form, so password sign-in stays on while LDAP is set up.