在 openId 授权码流程中使用最新版本的 Katana DLL 自动兑换代码(授权码)

nar*_*447 6 asp.net owin katana owin-middleware openid-connect

从最近的版本和下面的对话来看,现在 Katana(4.1.0) 支持带有自动代码兑换的代码流(这意味着我们没有显式调用 tokenendpoint 来兑换 idtoken、accesstoken 等代码)

https://github.com/aspnet/AspNetKatana/pull/297

所以,我已经升级了 Katana dll 并且有 p

Notifications = new OpenIdConnectAuthenticationNotifications()
                {
                    RedirectToIdentityProvider = OnRedirectToIdentityProvider,
                    //MessageReceived = OnMessageReceived, -- previous I were calling token endpoint in this notification
                    SecurityTokenReceived = notification => Task.FromResult(0),
                    SecurityTokenValidated = OnSecurityTokenValidated,
                    AuthenticationFailed = OnAuthenticationFailed,
                    AuthorizationCodeReceived = AuthorizationCodeReceived, -- added this notification per latest improvements
                    TokenResponseReceived = TokenResponseReceived
                }
Run Code Online (Sandbox Code Playgroud)

以及这里的实现

 private Task AuthorizationCodeReceived(AuthorizationCodeReceivedNotification arg)
    {
        return Task.FromResult(0);
    }
Run Code Online (Sandbox Code Playgroud)

我期望中间件调用令牌端点来兑换授权代码,但这不会发生。

我在这里错过了什么吗?我应该在此处添加一些代码以便中间件兑换代码吗?请各位指教..

更新:

我按照其他博客设置如下,

args.App.UseOpenIdConnectAuthentication(
                new OpenIdConnectAuthenticationOptions
                {
                   //other properties removed for brevity
                    SaveTokens = true,
                    RedeemCode = true,
}
Run Code Online (Sandbox Code Playgroud)

中间件仍然不会自动兑换代码。

只是想一下,.NET core 是否支持此功能?我实际上使用的是.NET Framework 4.7.1。

nar*_*447 6

实际上,上述设置正在工作并进行令牌 api 调用,但由于我的设置中缺少“clientsecret”而失败,一旦更正,一切工作正常。谢谢。