2016-05-31 51 views
1

看起來RC2中存在突破性的變化。.NET Core 1.0.0 RC2中的OpenIdConnectOptions中的通知在哪裏?

我試圖建立的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, 
    }; 
}); 

但拉姆達選項設置爲不可用。如果我嘗試使用新的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在那裏。任何人都知道什麼是新的設置?


更新

基於通過精確定位的答案,這是我更新的代碼:

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); 

} 

回答

2

沒有通知是那裏。任何人都知道什麼是新的設置?

Notifications物業更名爲EventsOpenIdConnectAuthenticationNotifications現在被命名OpenIdConnectEvents

相關問題