Ich habe einen Identity Provider mit OpenID Connect erstellt, um Authentifizierung und Autorisierung über OAuth2-Zugriffstoken bereitzustellen. Der Autorisierungs-Workflow auf dem Server funktioniert; Allerdings kann ich meinen ASP.NET Core-Client nicht dazu veranlassen, automatisch zum OpenID Connect-Provider umzuleiten, wenn die Authentifizierung fehlschlägt. Ich zur Zeit erhalte nur eine 401.ASP.NET Core & OpenID Connect Umleitung zu externem Identitätsanbieter
Hier ist meine startup.cs:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseCookieAuthentication();
var options = new OpenIdConnectOptions
{
Authority = "http://localhost:63467",
AutomaticAuthenticate = true,
AutomaticChallenge = true,
AuthenticationMethod = OpenIdConnectRedirectBehavior.RedirectGet,
AuthenticationScheme = "oidc",
ClientId = "2",
ClientSecret = "alskghalsd",
Configuration =
new OpenIdConnectConfiguration
{
AuthorizationEndpoint =
"http://localhost:63467/connect/authorize",
TokenEndpoint =
"http://localhost:63467/connect/token"
},
PostLogoutRedirectUri = "/",
ResponseType = "Code",
RemoteSignOutPath = "/signout",
UseTokenLifetime = true,
SaveTokens = true,
SignInScheme = "Cookies",
RequireHttpsMetadata = false
};
options.Scope.AddRange(new[] { "openid name role profile" });
app.UseOpenIdConnectAuthentication(options);
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}