diff --git a/samples/Sample.RabbitMQ.Postgres.DashboardAuth/Startup.cs b/samples/Sample.RabbitMQ.Postgres.DashboardAuth/Startup.cs index 481dcbbd3..4375f156e 100644 --- a/samples/Sample.RabbitMQ.Postgres.DashboardAuth/Startup.cs +++ b/samples/Sample.RabbitMQ.Postgres.DashboardAuth/Startup.cs @@ -62,6 +62,7 @@ public void ConfigureServices(IServiceCollection services) cap.UseDashboard(d => { d.UseChallengeOnAuth = true; + d.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme; d.Authorization = new[] {new HttpContextDashboardFilter()}; }); }); diff --git a/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs b/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs index 441fcf386..8fe214526 100644 --- a/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs +++ b/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs @@ -136,7 +136,7 @@ public async Task Invoke(HttpContext context) if (_options.UseChallengeOnAuth) { - await context.ChallengeAsync(); + await context.ChallengeAsync(_options.DefaultChallengeScheme); return; } diff --git a/src/DotNetCore.CAP.Dashboard/CAP.DashboardOptions.cs b/src/DotNetCore.CAP.Dashboard/CAP.DashboardOptions.cs index aec1f0dd5..f65937e9f 100644 --- a/src/DotNetCore.CAP.Dashboard/CAP.DashboardOptions.cs +++ b/src/DotNetCore.CAP.Dashboard/CAP.DashboardOptions.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using DotNetCore.CAP.Dashboard; +using Microsoft.AspNetCore.Authentication.Cookies; // ReSharper disable once CheckNamespace namespace DotNetCore.CAP @@ -18,6 +19,11 @@ public DashboardOptions() UseChallengeOnAuth = false; } + /// + /// Default ChallengeScheme used for Dashboard authentication. If no scheme is set, the DefaultScheme set up in AddAuthentication will be used. + /// + public string DefaultChallengeScheme { get; set; } + /// /// Indicates if executes a Challenge for Auth within ASP.NET middlewares ///