Skip to content

SSO with Entra ID

For: an app developer, or the Entra ID admin of a customer, who connects the customer’s Entra ID tenant to an organization.

What it does: this page gives the steps in the Microsoft Entra admin center for an OIDC connection and for a SAML connection. Each field name is the name on the Microsoft Learn pages that the last table lists, with the date of each read.

Pick one kind. OIDC needs fewer values.

  1. In the Microsoft Entra admin center, go to “Entra ID” > “App registrations” > “New registration”.
  2. Enter a “Name”. Under “Supported account types”, select “Single tenant only”.
  3. Select “Register”. Copy the “Application (client) ID” and the “Directory (tenant) ID”.
  4. Go to “Certificates & secrets” > “Client secrets” > “New client secret”. Copy its “Value” now.
  5. Create the connection with the values of steps 3 and 4, as entraOidc below does.
  6. Go to “Authentication” > “Add Redirect URI”, and select the “Web” platform.
  7. Enter <baseURL><basePath>/sso/<connectionId>/callback, with the id of the connection.

The issuer holds the tenant ID in GUID form, not the domain name of the tenant. Core reads the discovery document of the issuer, and that document names the GUID form. Core needs the two to be equal.

The secret has a life of at most 24 months. Before it ends, make a new one and update the connection with clientSecret.

  1. Go to “Entra ID” > “Enterprise apps” > “All applications”, and open the app of the customer.
  2. Select “Single sign-on”, then “SAML”.
  3. Copy the “Login URL” and the “Microsoft Entra Identifier” of the “Set up” section.
  4. In “SAML Certificates”, download the certificate in the Base 64 form.
  5. Create the connection with these three values, as entraSaml below does.
  6. In “Basic SAML Configuration”, select “Edit”.
  7. Enter the spEntityId of the connection in “Identifier (Entity ID)”.
  8. Enter the acsUrl of the connection in “Reply URL (Assertion Consumer Service URL)”.
  9. In “Attributes & Claims”, select “Edit”, then “Add new claim”.
  10. Give the claim the name email, and the email address of the person as its source.
  11. Assign the people of the customer to the app, and select “Test”.

Core asks for the persistent NameID format when the connection has no subjectAttribute. Then core refuses a transient NameID. Entra ID honors the format of the request, so you change nothing in “Name identifier value”.

The connection input of Entra ID
import type { ConnectionInput } from "@authtempo/core";
/**
* An Entra ID app registration as an OIDC connection. The issuer holds the
* "Directory (tenant) ID" in GUID form, because the discovery document of
* the tenant names that issuer, and core needs the two to be equal.
*/
export function entraOidc(input: {
organizationId: string;
tenantId: string;
clientId: string;
clientSecret: string;
}): ConnectionInput {
return {
organizationId: input.organizationId,
kind: "oidc",
label: "Sign in with Microsoft",
issuer: `https://login.microsoftonline.com/${input.tenantId}/v2.0`,
clientId: input.clientId,
clientSecret: input.clientSecret,
};
}
/**
* An Entra ID enterprise app as a SAML connection, from the "Set up" section:
* the "Login URL", the "Microsoft Entra Identifier", and the Base64 certificate.
*/
export function entraSaml(input: {
organizationId: string;
loginUrl: string;
entraIdentifier: string;
certificatePem: string;
}): ConnectionInput {
return {
organizationId: input.organizationId,
kind: "saml",
label: "Sign in with Microsoft",
idpEntityId: input.entraIdentifier,
ssoUrl: input.loginUrl,
certificates: [input.certificatePem],
// The claim that you add in "Attributes & Claims" with the name email.
attributes: { email: "email", name: null },
};
}
The connection of each provider as a test
import { createAuth, type DnsTxtPort } from "@authtempo/core";
import { createTestIdp } from "@authtempo/core/testing";
import { describe, expect, it } from "vitest";
import { API, call, harness, signIn } from "../support/harness.ts";
import { entraOidc, entraSaml } from "./sso-entra.ts";
import { googleOidc, googleSaml } from "./sso-google.ts";
import { oktaOidc, oktaSaml } from "./sso-okta.ts";
const APP = { kind: "app", name: "admin-page" } as const;
/** An app with OIDC and SAML connections on, and one organization of an owner. */
async function setup() {
const h = harness();
const dns: DnsTxtPort[] = [{ name: "a", txt: async () => [] }];
const auth = createAuth({
baseURL: API,
trustedOrigins: [],
secret: h.secret,
storage: h.storage,
mail: h.mail,
organizations: {},
sso: { oidc: true, saml: true, dns },
});
const owner = await signIn(auth, h, "owner@owner.example");
const made = await call(
auth,
"POST",
"/auth/organizations/create",
{ slug: "acme", name: "Acme" },
{ cookie: owner },
);
const { organization } = (await made.json()) as { organization: { id: string } };
const sso = auth.api.sso;
if (!sso) throw new Error("sso is off");
return { sso, organizationId: organization.id };
}
describe("the connection of each provider", () => {
it("takes the OIDC values of Entra ID, Okta, and Google", async () => {
const { sso, organizationId } = await setup();
const inputs = [
entraOidc({
organizationId,
tenantId: "aaaabbbb-0000-cccc-1111-dddd2222eeee",
clientId: "client-1",
clientSecret: "secret-1",
}),
oktaOidc({
organizationId,
oktaDomain: "acme.okta.com",
clientId: "client-2",
clientSecret: "secret-2",
}),
googleOidc({ organizationId, clientId: "client-3", clientSecret: "secret-3" }),
];
const issuers: string[] = [];
const methods: string[] = [];
for (const input of inputs) {
const made = await sso.connections.create({ actor: APP, ...input });
if (!made.ok) throw new Error(`${made.code} ${made.message ?? ""}`);
issuers.push(made.value.oidc?.issuer ?? "");
methods.push(made.value.oidc?.tokenEndpointAuthMethod ?? "");
// No answer holds the client secret.
expect(JSON.stringify(made.value)).not.toContain("secret-");
}
expect(issuers).toEqual([
"https://login.microsoftonline.com/aaaabbbb-0000-cccc-1111-dddd2222eeee/v2.0",
"https://acme.okta.com",
"https://accounts.google.com",
]);
// Okta's default method is HTTP Basic; Entra ID and Google take the default of a connection.
expect(methods).toEqual(["client_secret_post", "client_secret_basic", "client_secret_post"]);
});
it("takes the SAML values of Entra ID, Okta, and Google, and answers the values for the provider", async () => {
const { sso, organizationId } = await setup();
const idp = await createTestIdp({ alg: "rsa" });
const inputs = [
entraSaml({
organizationId,
loginUrl: "https://login.microsoftonline.com/aaaabbbb-0000-cccc-1111-dddd2222eeee/saml2",
entraIdentifier: "https://sts.windows.net/aaaabbbb-0000-cccc-1111-dddd2222eeee/",
certificatePem: idp.certificatePem,
}),
oktaSaml({
organizationId,
ssoUrl: "https://acme.okta.com/app/acme/sso/saml",
issuer: "http://www.okta.com/exk1",
certificatePem: idp.certificatePem,
}),
googleSaml({
organizationId,
ssoUrl: "https://accounts.google.com/o/saml2/idp?idpid=C01",
entityId: "https://accounts.google.com/o/saml2?idpid=C01",
certificatePem: idp.certificatePem,
}),
];
for (const input of inputs) {
const made = await sso.connections.create({ actor: APP, ...input });
if (!made.ok) throw new Error(`${made.code} ${made.message ?? ""}`);
const id = made.value.id;
expect(made.value.saml?.attributes).toEqual({ email: "email", name: null });
// The two values that each admin console asks for.
expect(made.value.saml?.spEntityId).toBe(`${API}/auth/sso/${id}/metadata`);
expect(made.value.saml?.acsUrl).toBe(`${API}/auth/sso/${id}/acs`);
}
});
});
  • Entra ID signs the Assertion with the certificate of the app. Core verifies it with the certificate of the connection, never with a key of the document.
  • A connection holds one or two certificates. To roll the key over, add the new certificate to certificates, activate it in Entra ID, then remove the old one.
  • Each address must be in a verified domain of the organization. A person of the tenant with another address gets sso_domain_mismatch.
  • Core sends the client secret in the body of the token request.
  • sso_failed: the log line names the step. discovery means a wrong tenant form in the issuer. audience means a wrong “Identifier (Entity ID)”. destination or subject_confirmation means a wrong “Reply URL”. address means no claim email. subject means a NameID that is not persistent.
  • sso_domain_mismatch: the claim email holds an address outside the verified domains.
  • email_required: the ID token of an OIDC sign-in holds no address.
  • sso_not_configured: the connection is off, or the config does not turn its kind on.
  • invalid_body: the connection create refused a value. The message names the field.
Page Read (UTC) Updated on the page
Register an application 2026-10-23 20:58 2026-06-05
Add a redirect URI 2026-10-23 20:59 2026-05-14
Add credentials 2026-10-23 20:59 2025-04-08
OpenID Connect on the Microsoft identity platform 2026-10-23 20:58 2026-06-30
Enable SAML single sign-on 2026-10-23 20:58 2025-07-10
Customize SAML token claims 2026-10-23 21:10 2025-05-14
Manage certificates for federated single sign-on 2026-10-23 20:59 2026-03-11