2023-06-08 09:39:19 +00:00
|
|
|
using Elsa.EntityFrameworkCore.Modules.Identity;
|
|
|
|
|
using Elsa.EntityFrameworkCore.Modules.Management;
|
|
|
|
|
using Elsa.EntityFrameworkCore.Modules.Runtime;
|
2023-04-25 20:15:11 +00:00
|
|
|
using Elsa.Extensions;
|
|
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
var services = builder.Services;
|
|
|
|
|
|
|
|
|
|
// Add Elsa services.
|
|
|
|
|
services.AddElsa(elsa => elsa
|
2023-04-27 13:30:58 +00:00
|
|
|
// Add the Fluent Storage workflow definition provider.
|
2023-04-25 20:15:11 +00:00
|
|
|
.UseFluentStorageProvider()
|
|
|
|
|
|
|
|
|
|
// Expose API endpoints.
|
|
|
|
|
.UseWorkflowsApi()
|
2023-06-08 09:39:19 +00:00
|
|
|
|
|
|
|
|
.UseWorkflowManagement(management => management.UseEntityFrameworkCore())
|
|
|
|
|
.UseWorkflowRuntime(runtime => runtime.UseEntityFrameworkCore())
|
2023-04-25 20:15:11 +00:00
|
|
|
|
|
|
|
|
// Configure identity so that we can create a default admin user.
|
|
|
|
|
.UseIdentity(identity =>
|
|
|
|
|
{
|
|
|
|
|
identity.UseAdminUserProvider();
|
2023-06-08 09:39:19 +00:00
|
|
|
identity.UseEntityFrameworkCore();
|
2023-04-25 20:15:11 +00:00
|
|
|
identity.TokenOptions = options =>
|
|
|
|
|
{
|
|
|
|
|
options.SigningKey = "secret-token-signing-key";
|
|
|
|
|
options.AccessTokenLifetime = TimeSpan.FromDays(1);
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
|
2023-05-28 16:35:45 +00:00
|
|
|
// HTTP workflows.
|
|
|
|
|
.UseHttp()
|
|
|
|
|
|
2023-04-25 20:15:11 +00:00
|
|
|
// Use default authentication (JWT).
|
|
|
|
|
.UseDefaultAuthentication(auth => auth.UseAdminApiKey())
|
|
|
|
|
);
|
|
|
|
|
|
2023-06-08 09:39:19 +00:00
|
|
|
services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()));
|
|
|
|
|
|
2023-04-25 20:15:11 +00:00
|
|
|
// Configure middleware pipeline.
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
|
|
|
|
|
if (app.Environment.IsDevelopment())
|
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
|
|
|
|
|
|
// Configure the HTTP request pipeline.
|
|
|
|
|
app.UseAuthentication();
|
|
|
|
|
app.UseAuthorization();
|
2023-06-08 09:39:19 +00:00
|
|
|
app.UseCors();
|
2023-04-25 20:15:11 +00:00
|
|
|
app.UseWorkflowsApi();
|
2023-05-28 16:35:45 +00:00
|
|
|
app.UseWorkflows();
|
2023-04-25 20:15:11 +00:00
|
|
|
app.Run();
|