Ранее приложение использовало аутентификацию OWIN для входа в систему.
Версия приложения .NET Framework 4.8< /code>
Итак, для входа в систему Entra я обновил пакеты NuGet до последней версии и добавил несколько дополнительных пакетов.
Код: Выделить всё
Microsoft.Owin -Version 4.2.2
Microsoft.Owin.Host.SystemWeb -Version 4.2.2
Microsoft.Owin.Security -Version 4.2.2
Microsoft.Owin.Security.Cookies -Version 4.2.2
Microsoft.Owin.Security.OpenIdConnect -Version 4.2.2
Microsoft.IdentityModel.Protocols.OpenIdConnect -Version 8.3.0
Microsoft.IdentityModel.Tokens -Version 8.3.0
Код: Выделить всё
using System;
using System.Configuration;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using Microsoft.IdentityModel.Tokens;
using Microsoft.Owin;
using Microsoft.Owin.Security;
using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.Google;
using Owin;
using TorquexMediaPlayer.Models;
namespace TorquexMediaPlayer
{
public partial class Startup
{
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app)
{
// These values can be stored in Web.config or appSettings.json
string clientId = ConfigurationManager.AppSettings["ClientId"];
string clientSecret = ConfigurationManager.AppSettings["ClientSecret"];
string tenantId = ConfigurationManager.AppSettings["TenantId"];
// e.g., "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" or "mytenant.onmicrosoft.com"
// Authority format: "https://login.microsoftonline.com/{tenantId}/v2.0"
string authority = $"https://login.microsoftonline.com/{tenantId}/v2.0";
// CookieAuthentication must be enabled for OWIN to store user information after sign-in
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
// Configure the OpenIdConnect middleware
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
RedirectUri = "https://localhost:44300/signin-oidc",
PostLogoutRedirectUri = "https://localhost:44300/",
Scope = OpenIdConnectScope.OpenIdProfile,
ResponseType = OpenIdConnectResponseType.CodeIdToken,
// Use the client secret to authenticate your app
ClientSecret = clientSecret,
// Token validation parameters
TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
// For single-tenant apps, validate the issuer to be your specific tenant
ValidIssuer = $"https://login.microsoftonline.com/{tenantId}/v2.0"
},
// Notification handlers
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = context =>
{
// Handle authentication failures
context.HandleResponse();
context.Response.Redirect("/Error?message=" + context.Exception.Message);
return System.Threading.Tasks.Task.FromResult(0);
}
}
});
}
}
Код: Выделить всё
'IAppBuilder' does not contain a definition for 'UseOpenIdConnectAuthentication' and no accessible extension method 'UseOpenIdConnectAuthentication' accepting a first argument of type 'IAppBuilder' could be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'OpenIdConnectAuthenticationOptions' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'OpenIdConnectAuthenticationNotifications' could not be found (are you missing a using directive or an assembly reference?)
Я удалил все связанные пакеты и переустановил их, но проблема осталась.
Пыталась понизить версию пакетов, но проблема осталась.
Как решить эту проблему?
Подробнее здесь: https://stackoverflow.com/questions/793 ... entication
Мобильная версия