elsa-core/samples/aspnet/Elsa.Samples.AspNet.Onboarding.WorkflowServer/Program.cs
Sipke Schoorstra b4cd4dd465
Replace custom webhooks implementation with WebhooksCore (#5811)
* Replace custom webhooks implementation with WebhooksCore

Replaced the existing custom webhooks registration and dispatching system with the WebhooksCore library. This involved removing all previous custom webhook classes and interfaces, updating project dependencies, and modifying appsettings and program files to use the new configuration. The update simplifies the webhook handling architecture and leverages the features provided by WebhooksCore.

* Hide API key in Datadog Docker compose file

This change replaces the exposed Datadog API key with a placeholder "<HIDDEN>". This enhances security by preventing the API key from being visible in the version control system.
2024-07-21 16:48:38 +02:00

65 lines
1.9 KiB
C#

using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Elsa.Extensions;
using Elsa.Samples.AspNet.Onboarding.WorkflowServer.Workflows;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddElsa(elsa =>
{
// Add workflow.
elsa.AddWorkflow<OnboardingWorkflow>();
// Configure management feature to use EF Core.
elsa.UseWorkflowManagement(management => management.UseEntityFrameworkCore());
elsa.UseWorkflowRuntime(runtime =>
{
runtime.UseEntityFrameworkCore();
});
elsa.UseIdentity(identity =>
{
identity.TokenOptions = options =>
{
options.SigningKey = "c7dc81876a782d502084763fa322429fca015941eac90ce8ca7ad95fc8752035";
options.AccessTokenLifetime = TimeSpan.FromDays(1);
};
identity.UseAdminUserProvider();
});
// Expose API endpoints.
elsa.UseWorkflowsApi();
// Use default authentication (JWT + ApiKey).
elsa.UseDefaultAuthentication(auth => auth.UseAdminApiKey());
elsa.UseJavaScript();
// Enable SignalR for sending events to Elsa Studio for real-time updates.
elsa.UseRealTimeWorkflows();
// Use Webhooks feature.
elsa.UseWebhooks(webhooks => webhooks.ConfigureSinks = options => builder.Configuration.GetSection("Webhooks:Sinks").Bind(options));
});
builder.Services.AddHealthChecks();
builder.Services.AddControllers();
builder.Services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().WithExposedHeaders("*")));
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseCors();
app.UseHttpsRedirection();
app.MapHealthChecks("/");
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseWorkflowsApi();
app.UseJsonSerializationErrorHandler();
app.UseWorkflows();
app.UseWorkflowsSignalRHubs();
app.Run();