elsa-core/samples/aspnet/Elsa.Samples.AspNet.Webhooks.WorkflowServer/Program.cs

35 lines
990 B
C#
Raw Normal View History

using Elsa.Extensions;
2023-06-08 10:01:26 +00:00
using Elsa.Samples.AspNet.Webhooks.WorkflowServer.Workflows;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddHandlersFrom<Program>();
builder.Services.AddElsa(elsa =>
{
elsa.AddWorkflow<HungryWorkflow>()
.UseHttp()
.UseIdentity(identity =>
{
identity.UseAdminUserProvider();
identity.TokenOptions = options =>
{
options.SigningKey = "secret-token-signing-key";
options.AccessTokenLifetime = TimeSpan.FromDays(1);
};
})
.UseWorkflowsApi()
.UseDefaultAuthentication(auth => auth.UseAdminApiKey())
.UseWebhooks(webhooks => webhooks.WebhookOptions = options => builder.Configuration.GetSection("Webhooks").Bind(options));
});
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseHttpsRedirection();
app.UseAuthentication();
app.UseAuthorization();
app.UseWorkflowsApi();
app.UseWorkflows();
app.Run();