Skip to main content

OIDC with Active Directory

Active Directory on its own does not speak OpenID Connect, and ProjectAchilles never takes a password or binds to LDAP itself. To sign in with AD accounts, put an OIDC provider in front of AD and point the console's OIDC sign-in at that provider:

If your AD is already synchronised to Microsoft Entra ID, use Entra ID directly instead: that route is validated end to end.

What was validated

Keycloak was validated live with ProjectAchilles (see Keycloak), with users of its own. The LDAP federation step on this page was not tested against Active Directory with ProjectAchilles. Try a sign-in for each role, a person with no role, and a disabled account (below) before you rely on it.

Whatever sits in front of AD, the console needs four things from it:

  1. a confidential client with a client secret, using the authorization code flow, with the redirect URI https://achilles.example.com/api/auth/oidc/callback;
  2. the person's console role as a value in a claim of the ID token (roles by default, or the name you set in OIDC_ROLE_CLAIM), matching OIDC_ROLE_MAP;
  3. a refresh token, so the console can re-check each person every OIDC_REVALIDATE_MINUTES (see When access ends);
  4. a refusal of that refresh token once the account is disabled, so the re-check ends their access.

Keycloak with LDAP user federation​

Set up the realm, the client, the client roles and the roles mapper as on the Keycloak page, steps 1 to 4. Then connect AD and turn AD groups into the console's client roles.

Connect AD​

In the realm, open User federation and add an LDAP provider:

  • Vendor: Active Directory.
  • Connection URL: ldaps://dc01.example.org:636. Use LDAPS: Keycloak sends AD the passwords people type. Keycloak must trust the domain controllers' certificate (a Keycloak setting, not a console one).
  • Bind type: simple, with a Bind DN and Bind credentials of a service account that can read users and groups and nothing more.
  • Edit mode: READ_ONLY. AD stays the source of truth.
  • Users DN: the OU that holds the people who may use the console, for example OU=Staff,DC=example,DC=org.
  • Username LDAP attribute: sAMAccountName (or userPrincipalName), whichever people type to sign in.

Save, then test the connection and the bind from the same page.

Turn AD groups into console roles​

Create four AD groups, for example Achilles-Admins, Achilles-Operators, Achilles-Analysts and Achilles-Explorers, in one OU, and add people to them. Then, on the LDAP provider's Mappers tab, add a mapper of type role-ldap-mapper:

  • LDAP Roles DN: the OU that holds the four groups;
  • Role Name LDAP Attribute: cn;
  • Role Object Classes: group;
  • Membership LDAP Attribute: member;
  • Mode: READ_ONLY;
  • Use Realm Roles Mapping: Off;
  • Client ID: the console's client (achilles).

Each group becomes a client role of the console's client with the group's name, and the roles mapper from the Keycloak page puts it into the ID token's roles claim. Map the group names to console roles:

OIDC_ROLE_MAP='admin=Achilles-Admins,operator=Achilles-Operators,analyst=Achilles-Analysts,explorer=Achilles-Explorers'

Values are compared case for case, so write them exactly as the groups are named. You can delete the four client roles you created by hand on the Keycloak page, or keep them for people who are not in AD.

Check before going live​

  • The offline_access role. Federated users may not get the realm's default roles. A user without the offline_access role cannot sign in (the backend logs error="not_allowed"). Check one federated user's Role mapping tab; if default-roles-<realm> is missing, assign it (see Keycloak: refresh tokens).
  • A disabled AD account must end access. Disable a test account in AD, wait one OIDC_REVALIDATE_MINUTES, and check that its next console request fails and the backend logs was marked inactive. If it keeps access, Keycloak is not refusing the refresh token for disabled AD accounts; fix that in Keycloak before relying on it.
  • A person removed from every group must land on "Your account has no role in this console." at their next sign-in or re-check.

AD FS​

AD FS is not supported today

The console cannot get a role from AD FS, for two reasons:

  • Roles in the ID token. The console reads the role from the ID token only. AD FS adds extra claims, such as roles, to the ID token only when the sign-in asks for response_mode=form_post (and the allatclaims scope). The console's callback accepts the provider's answer in the address only (a GET), never a form post.
  • No configurable rules. The console sends no resource parameter, so AD FS issues its tokens for its default resource, urn:microsoft:userinfo, whose issuance rules cannot be configured. A rule that sends AD groups as roles never applies to the console's sign-in. Also, offline_access, which the console asks for to get a refresh token, is not an AD FS scope.

Both come from Microsoft's AD FS OpenID Connect/OAuth concepts and the console's code. Put Keycloak in front of AD instead. If your AD is synchronised to Entra ID, use Entra ID.

Claim names​

RouteThe claimOIDC_ROLE_CLAIMOIDC_ROLE_MAP values
Keycloak, role-ldap-mapper + User Client Role mapperroles (a list)roles (default)the AD group names
Keycloak, realm roles instead of client rolesrealm_access.roles, if your mapper adds it to the ID tokenrealm_access.rolesthe role names
Entra ID (AD synchronised to Entra)rolesroles (default)the app role Values