2016-05-31 8 views
1

Es sieht so aus, als ob es in RC2 eine Änderung gibt.Wo sind Benachrichtigungen in OpenIdConnectOptions in .NET Core 1.0.0 RC2?

Ich habe versucht, diesen Abschnitt der alten Code einzurichten verbinden die 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, 
    }; 
}); 

Aber die Lambda-Optionen Setup ist nicht verfügbar.

Wenn ich versuche, eine neue OpenIdConnectOptions zu verwenden.

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, 

}); 

Nein Notifications ist da. Wer weiß, wie das neue Setup ist?


aktualisieren

Basierend auf der Antwort von Pinpoint, hier ist meine aktualisierte Code:

app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions 
{ 
    ClientId = clientId, 
    Authority = authority, 
    PostLogoutRedirectUri = postLogoutRedirectUrl, 
    Events = new OpenIdConnectEvents 
    { 
     OnAuthenticationFailed = OnAuthenticationFailed 
    } 
}); 

und die OnAuthenticationFailed Methode ist:

private static Task OnAuthenticationFailed(AuthenticationFailedContext context) 
{ 
    context.HandleResponse(); 
    context.Response.Redirect($"/Home/Error?message={context.Exception.Message}"); 
    return Task.FromResult(0); 

} 

Antwort

2

Keine Benachrichtigungen ist Dort. Wer weiß, wie das neue Setup ist?

Die Notifications Eigenschaft wurde Events umbenannt und OpenIdConnectAuthenticationNotifications jetzt OpenIdConnectEvents gestattet.

Verwandte Themen