【问题标题】:OpenIddict authorization request not handledOpenIddict 授权请求未处理
【发布时间】:2020-04-27 15:00:00
【问题描述】:

我正在尝试将 OpenIddict 3.0 用于 SSO 应用程序。我按照文档中的步骤,创建了一个 Authorize 控制器,并添加了一个测试应用程序。当我尝试连接授权时,我得到了这个异常:

System.InvalidOperationException:未处理授权请求。要处理授权请求,请创建一个实现“IOpenIddictServerHandler”的类并使用“services.AddOpenIddict().AddServer().AddEventHandler()”注册它。
或者,启用直通模式以在稍后阶段处理它们。

我在文档或示例应用程序中找不到任何解释这意味着什么的内容。我错过了什么?


到目前为止,这是我的代码。在Startup.cs:

services.AddOpenIddict()
    .AddCore(o =>
    {
        o.UseEntityFrameworkCore().UseDbContext<ApplicationDbContext>();
    })
    .AddServer(o =>
    {
        o.SetTokenEndpointUris("/connect/token");
        o.SetAuthorizationEndpointUris("/connect/authorize");

        o.AllowAuthorizationCodeFlow();

        o.RegisterScopes(OpenIddictConstants.Scopes.Email);

        o.AcceptAnonymousClients();
        o.AddDevelopmentEncryptionCertificate()
            .AddDevelopmentSigningCertificate();
        o.UseAspNetCore()
            .EnableTokenEndpointPassthrough()
            .DisableTransportSecurityRequirement();
    })
    .AddValidation(o =>
    {
        o.UseLocalServer();
        o.UseAspNetCore();
    });

并测试应用描述:

var descriptor = new OpenIddictApplicationDescriptor
{
    ClientId = "test-app",
    DisplayName = "Test Application",
    PostLogoutRedirectUris = { new Uri("https://oidcdebugger.com/debug") },
    RedirectUris = { new Uri("https://oidcdebugger.com/debug") }
};

我正在使用OpenID Connect debugger 进行测试。

【问题讨论】:

    标签: c# asp.net-core openid-connect openiddict


    【解决方案1】:

    要在 MVC 控制器中处理授权请求,您必须告诉 OpenIddict 的 ASP.NET Core 主机使用传递模式,就像您对令牌端点所做的一样:

    services.AddOpenIddict()
        .AddServer(options =>
        {
            options.UseAspNetCore()
                   .EnableAuthorizationEndpointPassthrough() // Add this line.
                   .EnableTokenEndpointPassthrough()
                   .DisableTransportSecurityRequirement();
        });
    

    【讨论】:

      猜你喜欢
      • 2014-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-13
      • 2014-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多