elsa-core/samples/aspnet/Elsa.Samples.AspNet.DynamicActivityProvider/Program.cs
Sipke Schoorstra 0ecc09438e Update project reference and cleanup code
A reference to Elsa.EntityFrameworkCore.Sqlite.csproj was added in the Elsa.Samples.AspNet.DynamicActivityProvider.csproj, providing SQLite support. The Add method in ExpressionDescriptorRegistry.cs was reformatted for better readability. In the Program.cs file, the signing key was updated to meet the minimum length requirement and some unnecessary comments were removed.
2024-04-05 20:17:47 +02:00

51 lines
1.6 KiB
C#

using Elsa.EntityFrameworkCore.Modules.Identity;
using Elsa.EntityFrameworkCore.Modules.Management;
using Elsa.EntityFrameworkCore.Modules.Runtime;
using Elsa.Extensions;
using Elsa.Samples.AspNet.DynamicActivityProvider.ActivityProviders;
var builder = WebApplication.CreateBuilder(args);
var services = builder.Services;
// Add Elsa services.
services.AddElsa(elsa => elsa
// Expose API endpoints.
.UseWorkflowsApi()
.UseWorkflowManagement(management => management.UseEntityFrameworkCore())
.UseWorkflowRuntime(runtime => runtime.UseEntityFrameworkCore())
// Configure identity so that we can create a default admin user.
.UseIdentity(identity =>
{
identity.UseAdminUserProvider();
identity.UseEntityFrameworkCore();
identity.TokenOptions = options =>
{
options.SigningKey = "secret-token-signing-key-with-a-minimum-length-of-256-bits";
options.AccessTokenLifetime = TimeSpan.FromDays(1);
};
})
.UseJavaScript()
.UseHttp()
.UseDefaultAuthentication(auth => auth.UseAdminApiKey())
);
// Add custom activity provider.
services.AddActivityProvider<ApiActivityProvider>();
services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()));
// Configure middleware pipeline.
var app = builder.Build();
if (app.Environment.IsDevelopment())
app.UseDeveloperExceptionPage();
// Configure the HTTP request pipeline.
app.UseAuthentication();
app.UseAuthorization();
app.UseCors();
app.UseWorkflowsApi();
app.UseWorkflows();
app.Run();