看起来RC2发生了重大变化。
我试图使用旧代码的这一部分设置OpenId连接:
app.UseOpenIdConnectAuthentication(options =>
{
options.ClientId = Configuration.Get("AzureAd:ClientId");
options.Authority = String.Format(Configuration.Get("AzureAd:AadInstance"), Configuration.Get("AzureAd:Tenant"));
options.PostLogoutRedirectUri = Configuration.Get("AzureAd:PostLogoutRedirectUri");
options.Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = OnAuthenticationFailed,
};
});
但lambda选项设置不可用。
如果我尝试使用新的OpenIdConnectOptions
。
var clientId = Configuration.GetSection("AzureAD:ClientId").Value;
var azureADInstance = Configuration.GetSection("AzureAD:AzureADInstance").Value;
var tenant = Configuration.GetSection("AzureAD:Tenant").Value;
var postLogoutRedirectUrl = Configuration.GetSection("AzureAD:PostLogoutRedirectUrl").Value;
var authority = $"{azureADInstance}{tenant}";
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUrl,
});
没有Notifications
。任何人都知道新的设置是什么?
根据Pinpoint的回答,这是我更新的代码:
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUrl,
Events = new OpenIdConnectEvents
{
OnAuthenticationFailed = OnAuthenticationFailed
}
});
并且OnAuthenticationFailed
方法是:
private static Task OnAuthenticationFailed(AuthenticationFailedContext context)
{
context.HandleResponse();
context.Response.Redirect($"/Home/Error?message={context.Exception.Message}");
return Task.FromResult(0);
}
答案 0 :(得分:3)
没有通知。任何人都知道新的设置是什么?
Notifications
属性已重命名为Events
,OpenIdConnectAuthenticationNotifications
现已命名为OpenIdConnectEvents
。