Asp.net core .NET Core 1.0.0 RC2中OpenIdConnectOptions中的通知在哪里?
看起来RC2中出现了突破性的变化 我试图使用这段旧代码设置OpenId连接:Asp.net core .NET Core 1.0.0 RC2中OpenIdConnectOptions中的通知在哪里?,asp.net-core,asp.net-core-mvc,Asp.net Core,Asp.net Core Mvc,看起来RC2中出现了突破性的变化 我试图使用这段旧代码设置OpenId连接: app.UseOpenIdConnectAuthentication(options => { options.ClientId = Configuration.Get("AzureAd:ClientId"); options.Authority = String.Format(Configuration.Get("AzureAd:AadInstance")
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,
});
没有通知
。有人知道新的设置是什么吗
更新 根据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);
}
没有通知。有人知道新的设置是什么吗
Notifications
属性被重命名为Events
,OpenIdConnectAuthenticationNotifications
现在被命名为OpenIdConnectEvents