Plugins

Microsoft

Official plugin — Entra ID sign-in across personal, work, and school accounts with tenant-aware issuer checks.

Microsoft (Entra ID) is OIDC with a tenant twist: common discovery advertises an issuer with the {tenantid} placeholder, so the value you pin at start is a template validated against the concrete token at callback.

The one rule

Pick the audience first: tenant: "common" for everyone, organizations for work/school only, consumers for personal accounts, or a tenant GUID to lock sign-in to one directory.

Quick start

Register an app

In the Azure portal → Microsoft Entra ID → App registrations → New registration. Choose Accounts in any organizational directory and personal Microsoft accounts for common. Add your redirect URI under Web.

Plug it

src/app.ts
import { oke } from "okengine";
import { oauth } from "okengine/plugins";

export const app = oke({
  name: "shop",
  env: "dev",
  gate: { auth: {} },
}).plug(
  oauth({
    baseUrl: "https://app.example.com",
    providers: {
      microsoft: { enabled: true }, // tenant defaults to "common"
    },
  }),
);

Set the client secret

# .env.local
OAUTH_MICROSOFT_CLIENT_SECRET=...

Certificates are not used — the driver authenticates with the shared secret form field.

How identity works

AspectBehavior
Discovery{tenant}/oauth2/v2.0/.well-known/openid-configuration, cached
Issuer pinningflow stores https://login.microsoftonline.com/{tenantid}/v2.0; tokens must match it shape-for-shape
Tenant claimthe token's tid must be GUID-shaped and consistent with iss
SignatureRS256 against the tenant's published keys
Email trustOIDC email_verified claim

Consequence: an ID token minted by a different tenant fails the issuer template even though its signature is perfectly valid — the mix-up defense survives multi-tenancy.

Default scopes: openid, email, profile.

Options

OptionTypeDefaultMeaning
enabledbooleanfalseTurn the provider on
clientIdstringVault/env*\*OAUTH_MICROSOFT_CLIENT_ID
tenantstring"common"organizations, consumers, or a GUID
redirectUristring{baseUrl}…/microsoftExact registered URI
scopesstring[]driver defaultsExtra scopes
storeProviderTokensbooleanfalseKeep tokens in Vault

Surfaces

FlowPath
StartPOST /auth/oauth/microsoft/start
CallbackGET+POST /auth/oauth/callback/microsoft
LinkPOST /auth/oauth/microsoft/link

Troubleshooting

Learn more

  • OAuth — shared flows and security model
  • Google — plain single-issuer OIDC
  • Vault — where secrets live

Next

On this page