From b7649308b22ae4f6d5e2cb3e9626d0105d6401ae Mon Sep 17 00:00:00 2001 From: Mateus Viegas Date: Tue, 6 Apr 2021 07:33:08 +0100 Subject: [PATCH] Created DefaultChallengeScheme on CAP.DashboardOptions.cs to specify dashboard auth challenge scheme (#815) --- samples/Sample.RabbitMQ.Postgres.DashboardAuth/Startup.cs | 1 + src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs | 2 +- src/DotNetCore.CAP.Dashboard/CAP.DashboardOptions.cs | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/samples/Sample.RabbitMQ.Postgres.DashboardAuth/Startup.cs b/samples/Sample.RabbitMQ.Postgres.DashboardAuth/Startup.cs index 481dcbb..4375f15 100644 --- a/samples/Sample.RabbitMQ.Postgres.DashboardAuth/Startup.cs +++ b/samples/Sample.RabbitMQ.Postgres.DashboardAuth/Startup.cs @@ -62,6 +62,7 @@ namespace Sample.RabbitMQ.Postgres.DashboardAuth 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 441fcf3..8fe2145 100644 --- a/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs +++ b/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs @@ -136,7 +136,7 @@ namespace DotNetCore.CAP 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 aec1f0d..f65937e 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 @@ namespace DotNetCore.CAP 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 ///