Skip to main content

User Guide · for DomainMOD 5.0.0

Single Sign-On

On This Page

As of v5.0.0, people can sign in to DomainMOD through your organization's identity provider, such as Okta, Microsoft Entra ID, Google Workspace, Keycloak, or Authentik, using OpenID Connect. Signing in with a password keeps working alongside it, so nothing changes for anyone until you turn single sign-on on.

DomainMOD works with one provider at a time. Everything is set on Administration -> Single Sign-On, so there's nothing to add to config.inc.php, and nothing extra to set for Docker.

What You Need First

  • HTTPS. Single sign-on only works while the Full DomainMOD URL in Administration -> System Settings is this installation's https:// address, including its folder when DomainMOD isn't at the top of the site (such as https://example.com/domains), with no query or # part, and HTTPS is forced with $force_https = 1; in helpers/top.php, so the session cookie is always marked Secure. If either stops being true, single sign-on stops working, and users with password sign-in sign in with a password.
  • One address. The browser has to reach DomainMOD at the Full DomainMOD URL's own host and port, since that's where your provider sends it back. Keep every DomainMOD address off plain HTTP (redirect it to HTTPS).
  • A writable temp folder. DomainMOD's temp folder has to be writable by the web server.
  • MFA at the provider. A single sign-on sign-in skips DomainMOD's own MFA, since the provider handles the second step, so make sure your provider requires MFA.

Note

Behind a reverse proxy: the proxy has to pass on the public Host header, with its port when it isn't 443, and set X-Forwarded-Proto itself, replacing any value it's sent. DomainMOD's own plain HTTP port should only be reachable by the proxy. The Single Sign-On page's Test warns when the page was opened at a different host or port than the Full DomainMOD URL.

Setting It Up

  1. In your provider, register DomainMOD as a web application (a confidential OpenID Connect client that uses the authorization code flow). Copy the Redirect URI shown on Administration -> Single Sign-On, such as https://domainmod.example.com/sso/callback.php, into its allowed redirect addresses. DomainMOD always uses PKCE with S256, so turn it on where the provider offers it. A provider that only allows plain won't work. ID tokens have to be signed with RS256 (most providers' default), RS384, RS512, ES256, or ES384, with RSA keys of at least 2,048 bits, and for RS384 or RS512, the provider's published signing key has to name the algorithm.

  2. On Administration -> Single Sign-On, enter a Provider Name (shown on the sign-in button, such as Okta), the Issuer URL (exactly as the provider's discovery document gives it, including any trailing slash), the Client ID, and the Client Secret from your provider. Most providers take the secret as Client Secret Basic, which is the default. If yours only takes Client Secret Post, choose it under Send the Client Secret With (the provider's discovery document has to list it).

  3. Click Test. DomainMOD fetches the provider's discovery document and signing keys and says what it found. It never saves anything, and never shows the secret, so the Client Secret field is empty again afterwards. Test doesn't sign anyone in or use the secret.

  4. Enter the Client Secret again, turn on Use Single Sign-On, and click Save.

  5. If your own account isn't linked yet, link it from Settings -> Security (see Who Can Sign In), then sign in through the provider once, in another browser or a private window, before you rely on it (such as before setting Password Sign-In to Administrators Only).

The sign-in page then shows a Sign In With Okta button (with your provider's name) above the password form. Once an MFA key is set, the client secret is saved encrypted with it, like your other saved credentials (see Encrypting Saved Credentials).

Note

Every claim DomainMOD reads (the email address, its verification, names, and groups) has to be in the ID token, since DomainMOD doesn't call the provider's userinfo endpoint. The steps below say how for each provider.

Who Can Sign In

DomainMOD finds a person by the provider's own ID for them, never by their name or email, and each DomainMOD user can be linked to one account at the provider. Links belong to the Issuer URL, so changing it leaves linked users unable to sign in through the provider until they're linked again, and the old links work again if you change it back. Some providers give each app registration its own user IDs, so changing the Client ID can mean linking users again too, after you click Unlink for each of them on Administration -> Users, because their old links still belong to the same Issuer URL. The account with the username admin unlinks its own, since nobody else can edit it. A Save that changes either one needs the Client Secret entered again, even if it hasn't changed, unless Use Single Sign-On is off and you tick Remove the saved value under it instead. A person is linked in one of four ways:

  • From the Security page. While signed in with a password, and while Password Sign-In lets them sign in with one (an administrator, or anyone when it's set to Everyone), a user with Single Sign-On Allowed? on goes to Settings -> Security, enters their Current Password under Single Sign-On, clicks Continue, then Link Your Okta Account (with your provider's name), and signs in at the provider. DomainMOD then shows which account came back and asks them to confirm with Link the Account. They have ten minutes at the provider and five more to confirm, and if either runs out, they start again from the Security page.
  • With a link code. On Administration -> Users, open the user and click Make Link Code. DomainMOD shows an address once, which works once, for up to 24 hours. It stops working sooner when a Save changes the Issuer URL or Client ID, when a Roles From Groups change resets the user's roles, when a backup is restored, or when anything changes the user's MFA or sign-in access, such as turning their MFA on or off, an MFA reset, a change to either of their switches on Administration -> Users, deactivating them, or saving Require MFA for All Users on while they have password sign-in and no MFA. Make a new one then. A new code replaces the previous one, so only the newest address works. Give it to the user yourself, such as by email or chat, and only to them, since whoever uses it first links their provider account to this user. They open it (signing out first if they're signed in to DomainMOD as someone else), click Sign In With Okta there, sign in at the provider, and confirm with Link the Account, with the same ten and five minutes (if either runs out, they open the address again). From then on, they sign in with the sign-in page's Sign In With button (signing out first, if they're still signed in). It works for users without a password, and while only administrators can sign in with a password. Make Link Code works only for an active user with Single Sign-On Allowed? on and no linked account, so to replace a link, click Unlink first.
  • By email, on their first sign-in, when Link Accounts by Email is on: you add the user on Administration -> Users with their work email address, and their first sign-in links them. Only a user who has never signed in (a correct password counts, even if they never finished MFA), was never linked, and has Single Sign-On Allowed? on can be linked this way, never an administrator, and only when exactly one active user has the address, the provider says it's verified, and its domain is in Allowed Email Domains. Users who already existed when DomainMOD was upgraded to v5.0.0 count as having signed in, so link them from the Security page or with a link code instead. Turn it on only when your provider really verifies addresses and people can't change their own email without verifying it again. Microsoft Entra ID's email is never used for this.
  • By creating the user, when Create Users on First Sign-In is on. It needs Roles From Groups, so only people in one of the three groups are created, whatever their email domain (Allowed Email Domains isn't checked here). Google Workspace sends no groups, so for it leave Roles From Groups off and Create Users on First Sign-In on. DomainMOD then creates anyone with a verified address in an allowed domain as a read-only user. The ID token needs an email address of up to 100 characters that no DomainMOD user already has. Otherwise, the person is told to ask you to add them, so add the user yourself and link them. New users are read-only unless their group says otherwise, and they sign in only through the provider.

Someone the provider says is fine but who isn't linked, can't be linked by email, and can't be created is refused with "Ask your administrator to give you access." So is a linked user who isn't active, has Single Sign-On Allowed? off, or, with Roles From Groups on, isn't in any of its groups, so check those before linking them again.

Roles From Groups

Roles are set in DomainMOD by default. With Roles From Groups on, you name the Groups Claim (such as groups, or roles for Entra ID app roles) and up to three groups: an Administrator Group, a Read-Write Group, and a Read-Only Group. Each sign-in through the provider then needs the person to be in one of them, and sets the roles of a user without password sign-in from their groups. Group names have to match the values in the token exactly, including case. Someone in more than one gets the most access any of them gives. Someone in none of them, or whose token has no groups claim, is refused. Linking an account doesn't check groups, so someone linked from the Security page or with a link code is still refused at sign-in until they're in one.

Users with Password Sign-In? on keep the roles you set on Administration -> Users, whatever their groups, even if they only ever sign in through the provider. Turning Roles From Groups on or off, or changing the claim or a group while it's on, sets every user without password sign-in to read-only and not an administrator, so no roles are left over from the provider. While it's on, each of their sign-ins through the provider sets their roles from their groups again, so roles you set by hand for them don't last. With it off, set their roles on Administration -> Users.

Password Sign-In and the Break-Glass Account

  • For each user: Administration -> Users has a Password Sign-In? switch. Users created by single sign-on start with it off. You can turn it off for a linked user once they've signed in through the provider since the issuer, the client ID, the Roles From Groups settings, or Require the Provider to Report MFA last changed, while Single Sign-On Allowed? is on for them and single sign-on is working, so check they can sign in through the provider first. Turning it on again resets their password, emails it to the address on the form, and sets them to read-only and not an administrator unless you choose other roles in the same save. You can't change your own account's Password Sign-In (another administrator can). Only the account with the username admin can edit itself, so its Password Sign-In can't be turned off.
  • Single Sign-On Allowed: turning Single Sign-On Allowed? off for a user, on Administration -> Users, refuses every single sign-on sign-in and link for them. The same page shows the user's linked account for the current Issuer URL, with Unlink, which removes only that link and signs the user out of all their DomainMOD sessions.
  • For everyone: Administration -> System Settings -> Password Sign-In can be Everyone (the default) or Administrators Only. With Administrators Only, the sign-in page shows only the single sign-on button, with a Sign in with a password link that shows the password form, and only administrators get through it. It has no effect unless single sign-on is on and working. When it isn't (it's turned off, its stored keys are more than 24 hours old or can't be used, the temp folder isn't writable, or the client secret can't be read), every user with password sign-in can sign in with a password.
  • Break-glass: DomainMOD always keeps at least one active administrator who isn't read-only, signs in with a password, and has signed in with a password at least once, and refuses any change that would remove the last one. Users who already existed when DomainMOD was upgraded to v5.0.0 count as having signed in with a password, so check that the administrators you keep for this really can. That administrator can always sign in with a password (and MFA, once they've set it up), whatever the provider is doing, so make sure they set up MFA. Keep two such administrators, keep their MFA recovery codes and the MFA key somewhere safe (a restore without the key needs a recovery code), and check that DomainMOD's email works, since a reset password is sent by email.

Note

If your provider goes down: with Administrators Only, users who aren't administrators can't sign in until the provider is back, unless they have password sign-in. They can use the password form once 24 hours have passed since DomainMOD last fetched the provider's keys (then everyone gets the form), which can be sooner than 24 hours into the outage, or once an administrator sets Password Sign-In back to Everyone and clicks Update Password Sign-In Setting. Setting it to Everyone is quicker, and it also works when the provider's keys can still be fetched, but its sign-in fails. Users without password sign-in, administrators included, wait for the provider. Administrators with password sign-in can still sign in with a password.

Sessions and Signing Out

A single sign-on session ends after Session Length (1 to 24 hours, 12 by default), and the next sign-in checks the person again, so someone the provider removes, or whose groups no longer give them access, loses single sign-on access within that time. If they also have password sign-in, turn off Active Account? for them on Administration -> Users too. It also ends when single sign-on is turned off, its settings are saved, or a backup is restored. A restore also cancels every link code that hasn't been used, so make new ones afterwards. If the restore says single sign-on was turned off, set it up again on Administration -> Single Sign-On, and link users again.

Signing out ends DomainMOD's session only. With Also Sign Out of Okta (with your provider's name) on, signing out of a single sign-on session with DomainMOD's Logout also sends the browser to the provider to sign out there, when the provider's discovery document gives a sign-out address (end_session_endpoint). If the provider can't be reached then, its own session may stay open. Without one, only DomainMOD's session ends. Register the Sign-Out Return Address shown on the Single Sign-On page with your provider first.

Okta

  1. In the Okta Admin Console, go to Applications -> Create App Integration, choose OIDC - OpenID Connect and Web Application, and enter the Redirect URI.
  2. Under Client Credentials, turn on Require PKCE as additional verification.
  3. For groups, add a claim named groups to the ID token (on the authorization server's Claims tab, included in the ID token Always, or the app's Sign On tab), with a filter that matches the groups you use. With the org authorization server, also add groups to Extra Scopes.
  4. The issuer is https://<your org>.okta.com for the org authorization server, or https://<your org>.okta.com/oauth2/default for the default custom one. Use the one your app's tokens come from.
  5. Require MFA in the app's sign-on policy. Okta can report it in the amr claim, so Require the Provider to Report MFA can be turned on. DomainMOD then refuses any sign-in whose amr doesn't include mfa, so check that a sign-in still works after turning it on.

Microsoft Entra ID

  1. In App registrations, register a new application (single tenant), with a Web redirect URI.
  2. Under Certificates & secrets, make a client secret.
  3. For roles, define App roles and assign them to users, then use roles as the Groups Claim, and enter each role's Value (not its display name) in DomainMOD's group fields. Entra ID replaces a long groups claim with a pointer, which DomainMOD refuses, so app roles are the better choice. Remove the app's groups claim under Token configuration when you use them, since a token with the pointer is refused even then.
  4. Without Roles From Groups, turn on Assignment required on the enterprise application, so only assigned users can sign in. It doesn't apply to the tenant's Global Administrators, so app roles are the way to keep them out.
  5. To create users on first sign-in, add the email and xms_edov optional claims to the ID token. xms_edov has to be true, which means Microsoft has verified the owner of the email's domain. Without them, users are added by an administrator.
  6. The issuer is https://login.microsoftonline.com/<tenant id>/v2.0. The multi-tenant common issuer isn't accepted. Require MFA with Conditional Access. Leave Require the Provider to Report MFA off, since Entra ID doesn't send amr in these tokens.

Google Workspace

  1. In the Google Cloud console, create an OAuth client ID of type Web application, with the Redirect URI.
  2. The issuer is https://accounts.google.com. Google never sends groups, so set roles in DomainMOD (or create users as read-only, see above).
  3. Put your Workspace domain in Allowed Email Domains, plus any other domain your users' addresses use. Both the address's domain and the Workspace domain Google reports have to be listed, so only Workspace accounts in your domains can be linked by email or created.
  4. Require 2-Step Verification in the Admin console, and leave Require the Provider to Report MFA off.

Keycloak

  1. In your realm, create a client with Client authentication on and Standard flow only, with the Redirect URI and, for signing out, the Sign-Out Return Address as a valid post-logout redirect URI.
  2. Under the client's Advanced settings, set Proof Key for Code Exchange Code Challenge Method to S256.
  3. For groups, add a Group Membership mapper to the client (claim groups, Full group path on, Add to ID token on), and enter each group in DomainMOD with its full path, such as /IT/DomainMOD Admins, since two groups in different places can share a name.
  4. The issuer is https://<host>/realms/<realm>. Require MFA in the realm's browser flow, so every user needs a second factor and one without it has to set it up, not only those who already have one. The OTP and WebAuthn policies only configure the authenticator.

Authentik

  1. Create an OAuth2/OpenID Provider with the Redirect URI, then an application that uses it.
  2. Choose an RSA Signing Key for the provider, so tokens are signed with RS256 (Authentik uses HS256 without one, which DomainMOD refuses).
  3. Turn on Include claims in id_token, so the groups and email reach the ID token.
  4. Keep Subject mode on its hashed user ID default, never the email or username, which can be given to someone else.
  5. Since 2025.10, Authentik's default email mapping sends email_verified as false. Use Authentik's own email verification rather than mapping it to always be true, or leave Link Accounts by Email off.
  6. The issuer is https://<host>/application/o/<app slug>/, with the trailing slash. Require MFA in the authentication flow, with an Authenticator Validation stage that makes a user without an authenticator set one up (or denies them) rather than skipping it.

LDAP and Active Directory

DomainMOD doesn't connect to a directory itself. Keycloak and Authentik can sit in front of an LDAP or Active Directory server (Keycloak's User federation, Authentik's LDAP Sources) and offer it over OpenID Connect, and Microsoft Entra ID syncs on-premises Active Directory, so people sign in with their directory accounts through any of them.

Logging

With debugging on, sign-ins, refusals (and why), links, and new users go to the Debug Log, never with a token, code, or secret. DomainMOD records sso/callback.php and sso/link.php without their queries. Your web server and any proxy log the full address, so consider logging those two paths without their queries too.

Edit this page on GitHub