-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebApplicationExtensions.cs
More file actions
41 lines (38 loc) · 1.34 KB
/
WebApplicationExtensions.cs
File metadata and controls
41 lines (38 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Hangfire;
using Hangfire.Dashboard.BasicAuthorization;
using Logrus.Smith.Infra;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace Logrus.Smith;
public static class WebApplicationExtensions
{
public static void UseLogrusSmith(this WebApplication app)
{
var filter = new BasicAuthAuthorizationFilter(
new BasicAuthAuthorizationFilterOptions
{
RequireSsl = false,
SslRedirect = false,
LoginCaseSensitive = true,
Users =
[
new BasicAuthAuthorizationUser
{
Login = app.Configuration["LogrusSmithSettings:HangfireUser"],
PasswordClear = app.Configuration["LogrusSmithSettings:HangfirePassword"]
}
]
});
var options = new DashboardOptions
{
Authorization = [filter],
};
app.UseHangfireDashboard("/hangfire", options);
app.MapPost("/agent/{code}", async ([FromRoute] string code, [FromServices] AgentCallbackManager callbackManager, HttpRequest request) =>
{
var result = await callbackManager.InvokeCallback(code, request);
return Results.Ok(result);
});
}
}