Orchard Core Microsoft Authentication
Enable one or both external-authentication features:
| Feature ID | Settings path |
|---|---|
| OrchardCore.Microsoft.Authentication.MicrosoftAccount | Settings → Security → Authentication → Microsoft |
| OrchardCore.Microsoft.Authentication.AzureAD | Settings → Security → Authentication → Microsoft Entra ID |
Both depend on OrchardCore.Users.ExternalAuthentication. Register each
tenant's exact HTTPS callback URL at the provider. To accept personal
Microsoft accounts together with work or school accounts, use Entra ID with
tenant common instead of the Microsoft Account feature.
Microsoft Account
The default callback path is /signin-microsoft. The module's recipe step is
named MicrosoftAccountSettings and replaces AppId, AppSecret, and
CallbackPath:
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Microsoft.Authentication.MicrosoftAccount"
]
},
{
"name": "MicrosoftAccountSettings",
"AppId": "microsoft-application-id",
"CallbackPath": "/signin-microsoft"
}
]
}
The handler decrypts the stored AppSecret with data protection, as saved
from the admin page; a recipe-imported secret is stored as is and fails to
decrypt. Supply the secret from the admin page or configuration, and note that
re-running the step clears it. The generic Settings step also accepts a
MicrosoftAccountSettings object with SaveTokens.
In 4.0, MicrosoftAccountSettings.AppSecretSecretName can name a TextSecret
of the Secrets module instead; it takes precedence over AppSecret. With the
OrchardCore.Secrets feature enabled, the admin page offers Use a secret
(suggested name MicrosoftAccount.AppSecret), and a saved secret can be moved
without retyping it from Tools → Security → Migrate Secrets. The generic
Settings step can set "AppSecretSecretName": "MicrosoftAccount.AppSecret"
after a Secrets step created the secret; the dedicated step has no
secret-name property. Microsoft Entra ID has no client secret setting. See
Microsoft Entra ID
Register an app in the Azure Portal with redirect URI /signin-oidc, enable
access tokens and ID tokens under implicit and hybrid flows, and add the
optional email claim to the ID token so existing users can be matched by
email. The Entra recipe step is AzureADSettings:
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Microsoft.Authentication.AzureAD"
]
},
{
"name": "AzureADSettings",
"DisplayName": "Sign in with Microsoft Entra ID",
"AppId": "entra-application-id",
"TenantId": "organizations",
"CallbackPath": "/signin-oidc"
}
]
}
| TenantId | Who can sign in |
|---|---|
| Directory (tenant) ID | Accounts in your directory only |
| organizations | Any work or school account |
| common | Work, school, and personal Microsoft accounts |
Multi-tenant values broaden who can authenticate; combine them with
ExternalRegistrationSettings or login scripts to control local accounts.
Configuration Overrides
Call ConfigureMicrosoftAccountSettings() and/or ConfigureAzureADSettings()
on the OrchardCoreBuilder:
builder.Services
.AddOrchardCms()
.ConfigureMicrosoftAccountSettings()
.ConfigureAzureADSettings();
{
"OrchardCore": {
"Authentication": {
"MicrosoftAccount": {
"AppId": "microsoft-application-id",
"AppSecret": "plain-app-secret",
"CallbackPath": "/signin-microsoft",
"SaveTokens": false
},
"AzureAD": {
"DisplayName": "Contoso account",
"AppId": "entra-application-id",
"TenantId": "organizations",
"CallbackPath": "/signin-oidc",
"SaveTokens": false
}
}
}
}
The Microsoft Account AppSecret is a plain value here, for example from the
OrchardCore__Authentication__MicrosoftAccount__AppSecret environment
variable; Orchard Core protects it before use. In 4.0 it logs a
LegacySecretConfiguration warning (event 8100). The section binds onto
MicrosoftAccountSettings, so set AppSecretSecretName here instead to
reference a secret, and remove AppSecret.
Enable OrchardCore.Users.Registration only when external identities may
create local Orchard users; see orchardcore-users-roles for
ExternalRegistrationSettings and the external login scripts.
Upgrading from 3.x
- Rename
OrchardCore_Microsoft_Authentication_MicrosoftAccounttoOrchardCore:Authentication:MicrosoftAccountandOrchardCore_Microsoft_Authentication_AzureADtoOrchardCore:Authentication:AzureAD(old names still work but are deprecated). - A plain Microsoft Account
AppSecretfrom configuration is now honored; in 3.x it had to be already protected and was otherwise ignored. It logsLegacySecretConfiguration; move it to a secret. - Saved app secrets keep working. Code reading
MicrosoftAccountSettings.AppSecretdirectly must also honorAppSecretSecretName.