Skip to main content

Sign in against a directory

Check passwords against LDAP or Active Directory, so that people keep the account they already have.

RecipeDraftView source
This page is a draft. The code exists, and not all of it has been run for this page yet. The page says what was checked.
Packages
lumo
Works with
lumo CLI
Standards
LDAP

What it shows​

  1. You add the directory in the portal, with its address, a bind account and TLS.
  2. You name the directory attributes that fill the profile.
  3. A person signs in on the hosted page with the directory password. LumoAuth creates the account at the first sign-in.
  4. An account that has its own password is not linked by itself. An administrator links it with the CLI.

Before you start​

  • A directory that LumoAuth can reach on a public address, with a certificate from a public certificate authority. LumoAuth refuses a private address when you save: "LDAP server host must be a public, resolvable hostname or IP address". A directory in a container on your machine therefore does not work.
  • A bind account in the directory that may search for users.
  • Check that your plan includes LDAP in the plans matrix.
  • The lumo CLI, and an API key with the scopes admin:users:read and admin:users:write.
VariableValue
LUMOAUTH_URLThe address of LumoAuth: https://app.lumoauth.dev, or https://eu.app.lumoauth.dev for the EU region.
LUMOAUTH_ORG_IDYour organization, for example acme-corp.
LUMOAUTH_API_KEYAn API key with the scopes admin:users:read and admin:users:write.
LDAP_CONFIG_IDThe number of the directory connection. It is in the address of its edit page: /portal/ldap/1/edit.
USER_EMAILOptional. The account to link. The default is sam.rivera@northwind.example.com.
USER_DNOptional. The DN of the person in the directory. The default is uid=sam,ou=people,dc=northwind,dc=example,dc=com.

Add the directory in the portal:

  1. Open Settings, Integrations, and the section Directory sign-in (LDAP/AD). Click Add LDAP/AD directory.
  2. Display name: Northwind Labs directory.
  3. LDAP server URL: for example ldaps://ldap.northwind.example.com:636. The protocol and the port of the address set Use SSL (LDAPS) and Port when you save.
  4. Base DN: for example dc=northwind,dc=example,dc=com.
  5. Bind DN and Bind password: the bind account.
  6. User search filter: (uid={username}) for OpenLDAP, or (sAMAccountName={username}) for Active Directory.
  7. Username attribute, Email attribute, Name attribute, Given name attribute and Surname attribute: for OpenLDAP uid, mail, displayName, givenName and sn.
  8. Leave Just-in-time provisioning on, so that the first sign-in creates the account.
  9. Click Test and save. LumoAuth tests the connection first, and saves the directory only when the test passes.

Code​

Run each command from the recipes folder of the examples repository. Set the folder up once for your language. The form of the portal was followed up to the save. No directory sign-in was run: a directory in a local container is refused, because its address is not public.

b2b/ldap/cli/link.sh
#!/bin/sh
# Link an account that has a password to its entry in the directory, with the
# lumo CLI. After the link, the person signs in with the directory password.
#
# sh b2b/ldap/cli/link.sh
set -eu

USER_EMAIL="${USER_EMAIL:-sam.rivera@northwind.example.com}"
USER_DN="${USER_DN:-uid=sam,ou=people,dc=northwind,dc=example,dc=com}"

# The CLI reads its own three variables. With them it needs no `lumo login`.
export LUMO_BASE_URL="$LUMOAUTH_URL" LUMO_ORG="$LUMOAUTH_ORG_ID" LUMO_API_KEY="$LUMOAUTH_API_KEY"

echo "before:"
lumo users identities list "$USER_EMAIL" --output table

# Without --dn, LumoAuth searches the directory for the email address, then
# for the username. Add --ldap-only to turn off the password of the account,
# so that only the directory password signs the person in. The link signs the
# person out everywhere and sends them an email.
lumo users identities link "$USER_EMAIL" --ldap-config "$LDAP_CONFIG_ID" --dn "$USER_DN" > /dev/null

echo "after:"
lumo users identities list "$USER_EMAIL" --output table
sh b2b/ldap/cli/link.sh

Compiles. Not run against an organization. The script passes a syntax check and its first command ran. The link was not made: LumoAuth accepts only a directory on a public address, and the test had none.

Check the result​

Open the sign-in page of your organization. With a directory, the first field has the label Email or username. Sign in with a directory username and the directory password: LumoAuth creates the account, and fills the profile from the attributes.

A person who has an account with its own password is not linked at sign-in. Run the script for that account:

Output
before:
No federated identities linked.
after:
TYPE SOURCE IDENTITY NOTES
ldap Northwind Labs directory (#1) uid=sam,ou=people,dc=northwind,dc=example,dc=com
  • lumo users identities list on an account that the directory created shows the same kind of line, with the note "LDAP only".
  • LumoAuth sends the typed password to the directory, and the directory decides. A password that the directory refuses does not sign the person in.

Limits​

  • LumoAuth contacts the directory only when a person signs in. No job copies the directory. An account stays active when its entry leaves the directory, so block the account in LumoAuth too.
  • LumoAuth reads no groups and no phone numbers from the directory. Give roles in the portal or through the Admin API.
  • One of Use TLS (STARTTLS) and Use SSL (LDAPS) is required, and LumoAuth always verifies the certificate of the server.
  • An account that just-in-time provisioning created signs in with the directory password only. Passkeys, magic links and social sign-in still work for it.
  • An account signs in through one outside source at a time. LumoAuth refuses the link while the account is linked to SAML or to an OpenID Connect connection.