Skip to content

Commit

Permalink
Created DefaultChallengeScheme on CAP.DashboardOptions.cs to specify …
Browse files Browse the repository at this point in the history
…dashboard auth challenge scheme (#815)
  • Loading branch information
mviegas authored Apr 6, 2021
1 parent f0a763e commit b764930
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions samples/Sample.RabbitMQ.Postgres.DashboardAuth/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public void ConfigureServices(IServiceCollection services)
cap.UseDashboard(d =>
{
d.UseChallengeOnAuth = true;
d.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
d.Authorization = new[] {new HttpContextDashboardFilter()};
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public async Task Invoke(HttpContext context)

if (_options.UseChallengeOnAuth)
{
await context.ChallengeAsync();
await context.ChallengeAsync(_options.DefaultChallengeScheme);
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/DotNetCore.CAP.Dashboard/CAP.DashboardOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections.Generic;
using DotNetCore.CAP.Dashboard;
using Microsoft.AspNetCore.Authentication.Cookies;

// ReSharper disable once CheckNamespace
namespace DotNetCore.CAP
Expand All @@ -18,6 +19,11 @@ public DashboardOptions()
UseChallengeOnAuth = false;
}

/// <summary>
/// Default ChallengeScheme used for Dashboard authentication. If no scheme is set, the DefaultScheme set up in AddAuthentication will be used.
/// </summary>
public string DefaultChallengeScheme { get; set; }

/// <summary>
/// Indicates if executes a Challenge for Auth within ASP.NET middlewares
/// </summary>
Expand Down

0 comments on commit b764930

Please sign in to comment.