diff --git a/src/bundles/Elsa.AllInOne.Web/Elsa.AllInOne.Web.csproj b/src/bundles/Elsa.AllInOne.Web/Elsa.AllInOne.Web.csproj index 403dacdef..a0fa8f744 100644 --- a/src/bundles/Elsa.AllInOne.Web/Elsa.AllInOne.Web.csproj +++ b/src/bundles/Elsa.AllInOne.Web/Elsa.AllInOne.Web.csproj @@ -13,8 +13,11 @@ + + + diff --git a/src/bundles/Elsa.AllInOne.Web/Pages/Index.cshtml b/src/bundles/Elsa.AllInOne.Web/Pages/Index.cshtml index 1d19e4fed..3316da6bf 100644 --- a/src/bundles/Elsa.AllInOne.Web/Pages/Index.cshtml +++ b/src/bundles/Elsa.AllInOne.Web/Pages/Index.cshtml @@ -1,8 +1,8 @@ @page - - -
- -
-
\ No newline at end of file + +
+ +
+ + \ No newline at end of file diff --git a/src/bundles/Elsa.AllInOne.Web/Pages/Shared/_Layout.cshtml b/src/bundles/Elsa.AllInOne.Web/Pages/Shared/_Layout.cshtml index 8caaaa544..1ecbcea92 100644 --- a/src/bundles/Elsa.AllInOne.Web/Pages/Shared/_Layout.cshtml +++ b/src/bundles/Elsa.AllInOne.Web/Pages/Shared/_Layout.cshtml @@ -5,13 +5,13 @@ Elsa Workflows 3.0 - + @RenderBody() - + \ No newline at end of file diff --git a/src/bundles/Elsa.AllInOne.Web/Pages/Shared/_Layout.cshtml.css b/src/bundles/Elsa.AllInOne.Web/Pages/Shared/_Layout.cshtml.css deleted file mode 100644 index a72cbeaf3..000000000 --- a/src/bundles/Elsa.AllInOne.Web/Pages/Shared/_Layout.cshtml.css +++ /dev/null @@ -1,48 +0,0 @@ -/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification -for details on configuring this project to bundle and minify static web assets. */ - -a.navbar-brand { - white-space: normal; - text-align: center; - word-break: break-all; -} - -a { - color: #0077cc; -} - -.btn-primary { - color: #fff; - background-color: #1b6ec2; - border-color: #1861ac; -} - -.nav-pills .nav-link.active, .nav-pills .show > .nav-link { - color: #fff; - background-color: #1b6ec2; - border-color: #1861ac; -} - -.border-top { - border-top: 1px solid #e5e5e5; -} -.border-bottom { - border-bottom: 1px solid #e5e5e5; -} - -.box-shadow { - box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); -} - -button.accept-policy { - font-size: 1rem; - line-height: inherit; -} - -.footer { - position: absolute; - bottom: 0; - width: 100%; - white-space: nowrap; - line-height: 60px; -} diff --git a/src/bundles/Elsa.AllInOne.Web/Program.cs b/src/bundles/Elsa.AllInOne.Web/Program.cs index 153e59915..1a040437a 100644 --- a/src/bundles/Elsa.AllInOne.Web/Program.cs +++ b/src/bundles/Elsa.AllInOne.Web/Program.cs @@ -2,22 +2,40 @@ using Elsa.Extensions; using Elsa.Jobs.Extensions; using Elsa.Http; using Elsa.Http.Extensions; +using Elsa.Identity; +using Elsa.Identity.Extensions; +using Elsa.Identity.Features; +using Elsa.Identity.Options; using Elsa.JavaScript.Activities; using Elsa.JavaScript.Extensions; +using Elsa.Labels.Extensions; using Elsa.Scheduling.Activities; using Elsa.Liquid.Extensions; +using Elsa.Persistence.EntityFrameworkCore.Modules.ActivityDefinitions; +using Elsa.Persistence.EntityFrameworkCore.Modules.Labels; +using Elsa.Persistence.EntityFrameworkCore.Modules.Runtime; +using Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.ActivityDefinitions; +using Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Labels; +using Elsa.Persistence.EntityFrameworkCore.Sqlite.Modules.Runtime; +using Elsa.Requirements; using Elsa.Scheduling.Extensions; +using Elsa.Workflows.Api.Endpoints.WorkflowDefinitions.Post; +using Elsa.Workflows.Api.Features; using Elsa.Workflows.Core; using Elsa.Workflows.Core.Activities; -using Elsa.Workflows.Core.Activities.Flowchart.Activities; -using Elsa.Workflows.Core.Serialization; -using Elsa.Workflows.Core.Services; using Elsa.Workflows.Management.Extensions; -using Elsa.Workflows.Management.Serialization; using Elsa.Workflows.Runtime.Extensions; +using FastEndpoints; +using Microsoft.AspNetCore.Authentication.JwtBearer; +using Microsoft.AspNetCore.Authorization; var builder = WebApplication.CreateBuilder(args); var services = builder.Services; +var configuration = builder.Configuration; +var sqliteConnectionString = configuration.GetConnectionString("Sqlite"); +var identityOptions = new IdentityOptions(); +var identitySection = configuration.GetSection("Identity"); +identitySection.Bind(identityOptions); // Add Elsa services. services @@ -25,29 +43,40 @@ services .UseWorkflows() .UseWorkflowRuntime() .UseWorkflowManagement(management => management - .AddActivity() - .AddActivity() - .AddActivity() - .AddActivity() - .AddActivity() - .AddActivity() - .AddActivity() - .AddActivity() - .AddActivity() - .AddActivity() - .AddActivity() + .AddActivitiesFrom() + .AddActivitiesFrom() + .AddActivitiesFrom() + .AddActivitiesFrom() ) + .UseWorkflowApiEndpoints() + .UseIdentity(identity => + { + identity.CreateDefaultUser = true; + identity.IdentityOptions = options => identitySection.Bind(options); + }) + .UseWorkflowRuntime(runtime => { runtime.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)); }) + .UseLabels(labels => labels.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString))) + .UseActivityDefinitions(feature => feature.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString))) .UseJobs() .UseScheduling() .UseJavaScript() .UseLiquid() .UseHttp() .UseActivityDefinitions() - ); + ) + // Register FastEndpoints using collected assemblies from features. + .AddFastEndpointsFromModule(); -// Register serialization configurator for configuring what types to allow to be serialized. -services.AddSingleton(); -services.AddSingleton(); +services.AddHealthChecks(); + +// Authentication & Authorization. +services + .AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, identityOptions.ConfigureJwtBearerOptions); + +services.AddHttpContextAccessor(); +services.AddSingleton(); +services.AddAuthorization(options => options.AddPolicy(IdentityPolicyNames.SecurityRoot, policy => policy.AddRequirements(new LocalHostRequirement()))); // Razor Pages. services.AddRazorPages(); @@ -66,6 +95,7 @@ if (!app.Environment.IsDevelopment()) app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); +app.UseAuthentication(); app.UseAuthorization(); app.UseElsaFastEndpoints(); app.UseHttpActivities(); diff --git a/src/bundles/Elsa.AllInOne.Web/appsettings.json b/src/bundles/Elsa.AllInOne.Web/appsettings.json index 10f68b8c8..a61810ff8 100644 --- a/src/bundles/Elsa.AllInOne.Web/appsettings.json +++ b/src/bundles/Elsa.AllInOne.Web/appsettings.json @@ -1,9 +1,16 @@ { "Logging": { "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" + "Default": "Debug", + "Microsoft.EntityFrameworkCore": "Warning", + "Microsoft.AspNetCore": "Debug" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "ConnectionStrings": { + "Sqlite": "Data Source=elsa.sqlite.db;Cache=Shared;" + }, + "Identity": { + "SigningKey": "secret-signing-key" + } }