Мне не удалось выполнить аутентификацию приложения Azure AD B2C в веб-интерфейсе микрослужбы dotnet 5.0.
Я ссылался на руководства, относящиеся к проекту, размещенному по адресу: https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2.git
.В файле Startup.cs в разделе ConfigureServices я попробовал следующее в соответствии с примером проекта:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(
options => {
Configuration.Bind("AzureAdB2C", options);
options.TokenValidationParameters.NameClaimType = "name";
},
options => { Configuration.Bind("AzureAdB2C", options);}
);
Я получаю следующее сообщение об ошибке:
Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler: Error: Exception occurred while processing message.
System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'https://xxxxxx.b2clogin.com/Tenant-xxx-xxx-xxx-xxxxxxID/v2.0/.well-known/openid-configuration'
---> System.IO.IOException: IDX20807: Unable to retrieve document from: 'https://xxxxxx.b2clogin.com/Tenant-xxx-xxx-xxx-xxxxxxID/v2.0/.well-known/openid-configuration'. HttpResponseMessage: 'StatusCode: 404, ReasonPhrase: 'Not Found', ...
Я также попробовал следующее:
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(Configuration.GetSection("AzureAdB2C"));
Приведенный выше метод аутентификации возвращает HTML-страницу шаблона входа в систему.
Ссылаясь на проект, который не включал TenantId в appsettings.json, я получил сообщение об ошибке, жалующееся на отсутствие TenantId. Итак, теперь в appsettings.json у меня есть следующие данные:
"AzureAdB2C": {
"Instance": "https://xxxxxx.b2clogin.com/",
"ClientId": "xxxx-xxx-xxx-xx-xxxx",
"Domain": "xxxxxx.onmicrosoft.com/",
"SigninPolicyId":"B2C_1_testsusi",
"TenantId": "Tenant-xxx-xxx-xxx-xxxxxxID"
}
Любая помощь приветствуется!