Skip to content
Operate

Microsoft Entra ID

Sign in to the engine with Microsoft Entra ID over OIDC, with roles from Entra groups or app roles.

On this page

Connect the engine to Microsoft Entra ID (formerly Azure AD) as an OpenID Connect app. People then sign in with their Entra account, Entra's Conditional Access and MFA apply, and their Entra groups decide their engine role. Entra also speaks SAML: if your team prefers it, follow SAML 2.0 instead.

Before you start

  • An Entra tenant where you can register applications.
  • The engine on https, with ENGINE_PUBLIC_URL set, for example https://engine.example.test.
  • An engine admin who can sign in with a password, as a fallback.

Steps

1. Register the app

In the Entra admin center, open App registrations → New registration. Name it MedHook engine, choose Accounts in this organizational directory only, and add a Web redirect URI: https://engine.example.test/api/auth/sso/oidc/callback. If you add the IdP in Settings → Single sign-on instead of the environment, use its id in place of oidc.

2. Create a client secret

Under Certificates & secrets, add a client secret. Copy its Value now: Entra shows it once. Put it in your secrets manager as ENGINE_OIDC_CLIENT_SECRET.

3. Send groups in the token

Under Token configuration → Add groups claim, choose Security groups (or Groups assigned to the application, which keeps the token small). Entra sends group object ids, not names, so map the ids.

4. Configure the engine

The issuer is the OpenID Connect metadata document URL on the app's Endpoints page without /.well-known/openid-configuration; it ends in /<tenant-id>/v2.0. Use your tenant's own issuer: the multi-tenant common and organizations endpoints are refused, because their discovery document names another issuer, and accepting any tenant would let accounts from other organizations sign in.

bash
ENGINE_OIDC_ISSUER=<issuer from the Endpoints page>
ENGINE_OIDC_CLIENT_ID=<Application (client) ID>
ENGINE_OIDC_CLIENT_SECRET=<from your secrets manager>
ENGINE_OIDC_LABEL="Microsoft"
ENGINE_OIDC_GROUP_ROLES="1f0c...-admins-object-id=admin;8d2e...-ops-object-id=operator"
# Entra id_tokens carry no email_verified claim. Let your own
# single-tenant directory's emails create new people (never link):
ENGINE_OIDC_TRUST_EMAIL=true

Add the email optional claim under Token configuration if your users' sign-in name is not their email address. Because Entra doesn't mark emails verified, existing engine accounts are not linked by email: each person links theirs once from Settings → Single sign-on → Other identity providers → Link my account.

5. Require MFA (optional)

Enforce MFA with a Conditional Access policy for the app. To make the engine refuse any sign-in Entra doesn't report as multi-factor, set ENGINE_OIDC_REQUIRE_MFA=true; Entra reports it in the amr claim. Set ENGINE_OIDC_TRUST_IDP_MFA=true if Entra's MFA should also replace an authenticator enrolled in MedHook.

6. Test

Restart the engine, open /sign-in and choose Continue with Microsoft. Sign in as a person in each mapped group and check their role in the People table under Settings → Users & roles. A person in no mapped group gets "Your account isn't in a group that has access to this engine."

🎉 Entra now decides who can sign in and with which role.

Reference