Подтвердить что ты не робот

Соединение ASP.NET MVC 4.5.2 с IdentityServer4

У меня есть веб-сайт, работающий на ASP.NET MVC 4.5.2. У меня есть сервер IdentityServer4, но когда я пытаюсь его аутентифицировать, я получаю:

invalid_request

Для ASP.NET Core MVC документация имеет:

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationScheme = "Cookies"
});
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
    AuthenticationScheme = "oidc",
    SignInScheme = "Cookies",

    Authority = "http://localhost:5000",
    RequireHttpsMetadata = false,

    ClientId = "mvc",
    SaveTokens = true
});

Я включил следующий пакет NuGet в свой проект Microsoft.Owin.Security.OpenIdConnect. Мой код выглядит следующим образом:

        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = "Cookies"
        });
        app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
        {
            AuthenticationType = "oidc",
            SignInAsAuthenticationType = "Cookies",

            Authority = "http://localhost:5000",

            ClientId = "mvc",
        });

Как правильно подключиться к нему?

4b9b3361

Ответ 1

ОК Я получил эту работу.

Вам необходимо добавить следующий пакет NuGet к вашему решению Microsoft.Owin.Security.OpenIdConnect.

My Startup.Auth.cs содержит

 public void ConfigureAuth(IAppBuilder app)
        {

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "Cookies"
            });

            app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
            {
                Authority = "http://localhost:5000", //ID Server
                ClientId = "demo",
                ResponseType = "id_token code",
                SignInAsAuthenticationType = "Cookies",
                RedirectUri = "http://localhost:51048/signin-oidc", //URL of website
                Scope = "openid",               
            });

        }

Конфигурация My Client в IdentityServer:

 public static IEnumerable<Client> GetClients()
        {
            return new List<Client> {
                new Client {
                    ClientId = "demo",
                    AllowedScopes = new List<string> { "openid"},
                    AllowedGrantTypes = GrantTypes.Hybrid,
                    RedirectUris = new List<string>{"http://localhost:51048/signin-oidc"},

                }
            };
        }