2022-12-31 15:16:43 +00:00
|
|
|
using Elsa.EntityFrameworkCore.Extensions;
|
2022-12-30 12:11:29 +00:00
|
|
|
using Elsa.EntityFrameworkCore.Modules.Management;
|
|
|
|
|
using Elsa.Extensions;
|
2023-01-05 12:55:08 +00:00
|
|
|
using Elsa.Identity;
|
|
|
|
|
using Elsa.Requirements;
|
2022-12-30 12:11:29 +00:00
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
|
|
|
// Add services to the container.
|
|
|
|
|
builder.Services.AddElsa(elsa =>
|
|
|
|
|
{
|
|
|
|
|
// Configure management feature to use EF Core.
|
2023-01-12 18:26:30 +00:00
|
|
|
elsa.UseWorkflowManagement(management =>
|
|
|
|
|
{
|
2023-01-13 18:10:20 +00:00
|
|
|
management.UseWorkflowDefinitions(dm => dm.UseEntityFrameworkCore(ef => ef.UseSqlite()));
|
2023-01-12 18:26:30 +00:00
|
|
|
management.UseWorkflowInstances(w => w.UseEntityFrameworkCore(ef => ef.UseSqlite()));
|
|
|
|
|
});
|
2022-12-30 12:11:29 +00:00
|
|
|
|
|
|
|
|
// Expose API endpoints.
|
|
|
|
|
elsa.UseWorkflowsApi();
|
|
|
|
|
|
|
|
|
|
// Add services for HTTP activities and workflow middleware.
|
|
|
|
|
elsa.UseHttp();
|
|
|
|
|
|
|
|
|
|
// Configure identity so that we can create a default admin user.
|
|
|
|
|
elsa.UseIdentity(identity =>
|
|
|
|
|
{
|
2023-01-01 21:54:07 +00:00
|
|
|
identity.IdentityOptions.CreateDefaultAdmin = builder.Environment.IsDevelopment();
|
|
|
|
|
identity.TokenOptions.SigningKey = "secret-token-signing-key";
|
2022-12-30 12:11:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Use default authentication (JWT).
|
|
|
|
|
elsa.UseDefaultAuthentication();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Configure CORS to allow designer app hosted on a different origin to invoke the APIs.
|
|
|
|
|
builder.Services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod()));
|
|
|
|
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
app.UseCors();
|
|
|
|
|
app.UseAuthentication();
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
app.UseWorkflowsApi();
|
|
|
|
|
app.UseWorkflows();
|
|
|
|
|
app.Run();
|