Skip to main content

Enterprise SSO with OpenID Connect

Connect an OpenID Connect identity provider, such as Entra ID, Okta or Google Workspace.

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

What it shows​

  1. You add the connection in the portal, with the issuer, the client ID and the client secret.
  2. An administrator links the account of each person to the connection. The script does that for one account.
  3. You give the connection an email domain, and send people of that domain to the identity provider.
  4. A linked person signs in through the identity provider.

Before you start​

  • An OpenID Connect identity provider on a public https address. LumoAuth refuses any other issuer with "The issuer must be a public HTTPS URL."
  • Check that your plan includes enterprise SSO in the plans matrix.
  • The lumo CLI and jq, and an API key with the scopes admin:users:read and admin:users:write.
  • An account for the person. The setup script of One organization for each customer creates sam.rivera@northwind.example.com.
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.
OIDC_IDP_IDThe number of the OpenID Connect connection. It is in the address of its edit page: /portal/oidc-idps/3/edit.
OIDC_SUBJECTThe value that the identity provider sends for the person in the claim sub, for example 00u1abcd2EFGH3ijk4x5.
USER_EMAILOptional. The account to link. The default is sam.rivera@northwind.example.com.

Add the connection in the portal:

  1. Open Settings, Integrations, and the section Enterprise SSO (OIDC). Under Add a provider, choose your provider, or Any OpenID Connect provider.
  2. The form shows Your callback URL: https://app.lumoauth.dev/orgs/acme-corp/oidc/rp/callback. Register it as a redirect URI of a web application at the identity provider.
  3. Enter the Display name, the Issuer URL, the Client ID and the Client secret. Leave the endpoints empty: LumoAuth reads them from the discovery document of the issuer.
  4. Leave User identifier claim at sub (subject).
  5. In the box Login page, enter the Email domains of the company. Leave Send people with these email domains here off for now.
  6. Click Add identity provider.

Code​

Run each command from the recipes folder of the examples repository. Set the folder up once for your language. Every version below was run against a LumoAuth organization. The script was run against a connection in a test organization. The sign-in through an identity provider was not run: it needs an OpenID Connect provider on a public https address.

b2b/oidc-sso/cli/link.sh
#!/bin/sh
# Link an account to an OpenID Connect connection, with the lumo CLI. Only a
# linked account can sign in through the connection.
#
# sh b2b/oidc-sso/cli/link.sh
set -eu

USER_EMAIL="${USER_EMAIL:-sam.rivera@northwind.example.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"

USER_ID=$(lumo users get "$USER_EMAIL" --output json | jq -r .data.id)

# Prints one line for each link of the account.
links() {
lumo users identities list "$USER_EMAIL" --output json \
| jq -r --arg when "$1" '.data.bindings | if length == 0 then "\($when): no link" else .[] | "\($when): \(.type), \(.idp_name), subject \(.subject)" end'
}

links "before"

# The subject is the value that the identity provider sends for this person in
# the claim `sub`. `lumo users identities link` has no flag for OpenID Connect,
# so `lumo api` calls the endpoint. The link signs the person out everywhere
# and sends them an email.
lumo api POST "/users/$USER_ID/identities" \
--data "{\"type\": \"oidc\", \"idp_id\": $OIDC_IDP_ID, \"subject\": \"$OIDC_SUBJECT\"}" > /dev/null

links "after"
sh b2b/oidc-sso/cli/link.sh

The portal does the same: open the user under Users, go to Federated identities, and choose Link OpenID Connect identity.

Check the result​

Output
before: no link
after: oidc, Northwind Labs OIDC, subject 00u1abcd2EFGH3ijk4x5
  • When every account of the domain is linked, edit the connection and turn on Send people with these email domains here. A person who types an address of the domain on the sign-in page then goes to the identity provider.
  • A person whose account is not linked sees "Your account is not linked to this identity provider yet." after the identity provider sent them back.
  • To remove a link, call lumo api DELETE /users/{id}/identities/oidc.

Limits​

  • This connection creates no accounts, and it does not link an account by its email address. An administrator links each identity first.
  • A sign-in through the connection does not change the profile of the account.
  • An account signs in through one outside source at a time. LumoAuth refuses the link while the account is linked to SAML, LDAP or a social provider.
  • The link stores the value of the user identifier claim. If you change that claim on the connection, link each account again with the new value.
  • A link signs the person out everywhere, and sends them an email.