2023-01-05 12:55:08 +00:00
|
|
|
using Elsa.Extensions;
|
2023-06-08 10:01:26 +00:00
|
|
|
using Elsa.Samples.AspNet.Webhooks.WorkflowServer.Workflows;
|
2023-01-05 12:55:08 +00:00
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
|
builder.Services.AddHandlersFrom<Program>();
|
|
|
|
|
|
|
|
|
|
builder.Services.AddElsa(elsa =>
|
|
|
|
|
{
|
|
|
|
|
elsa.AddWorkflow<HungryWorkflow>()
|
|
|
|
|
.UseHttp()
|
|
|
|
|
.UseIdentity(identity =>
|
|
|
|
|
{
|
2023-03-26 21:53:17 +00:00
|
|
|
identity.UseAdminUserProvider();
|
|
|
|
|
identity.TokenOptions = options =>
|
|
|
|
|
{
|
|
|
|
|
options.SigningKey = "secret-token-signing-key";
|
|
|
|
|
options.AccessTokenLifetime = TimeSpan.FromDays(1);
|
|
|
|
|
};
|
2023-01-05 12:55:08 +00:00
|
|
|
})
|
2023-04-22 18:43:54 +00:00
|
|
|
.UseWorkflowsApi()
|
|
|
|
|
.UseDefaultAuthentication(auth => auth.UseAdminApiKey())
|
2024-07-21 14:48:38 +00:00
|
|
|
.UseWebhooks(webhooks => webhooks.ConfigureSinks = options => builder.Configuration.GetSection("Webhooks:Sinks").Bind(options));
|
2023-01-05 12:55:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
app.UseAuthentication();
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
app.UseWorkflowsApi();
|
|
|
|
|
app.UseWorkflows();
|
|
|
|
|
app.Run();
|