Integrate the ElsaIdentity service into the application to enhance identity management features. This change complements the login module and ensures a more cohesive and extensible authentication setup.
58 lines
2.1 KiB
C#
58 lines
2.1 KiB
C#
using System.Text.Json;
|
|
using Elsa.Studio.Dashboard.Extensions;
|
|
using Elsa.Studio.Shell;
|
|
using Elsa.Studio.Shell.Extensions;
|
|
using Elsa.Studio.Workflows.Extensions;
|
|
using Elsa.Studio.Contracts;
|
|
using Elsa.Studio.Core.BlazorWasm.Extensions;
|
|
using Elsa.Studio.Extensions;
|
|
using Elsa.Studio.Login.BlazorWasm.Extensions;
|
|
using Elsa.Studio.Login.Extensions;
|
|
using Elsa.Studio.Login.HttpMessageHandlers;
|
|
using Elsa.Studio.Models;
|
|
using Elsa.Studio.Options;
|
|
using Elsa.Studio.Workflows.Designer.Extensions;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
|
using Microsoft.Extensions.Options;
|
|
using Microsoft.JSInterop;
|
|
|
|
// Build the host.
|
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
|
|
|
// Register root components.
|
|
builder.RootComponents.Add<App>("#app");
|
|
builder.RootComponents.Add<HeadOutlet>("head::after");
|
|
builder.RootComponents.RegisterCustomElsaStudioElements();
|
|
|
|
// Register shell services and modules.
|
|
var backendApiConfig = new BackendApiConfig
|
|
{
|
|
ConfigureBackendOptions = options => builder.Configuration.GetSection("Backend").Bind(options),
|
|
ConfigureHttpClientBuilder = options => options.AuthenticationHandler = typeof(AuthenticatingApiHttpMessageHandler)
|
|
};
|
|
|
|
builder.Services.AddCore();
|
|
builder.Services.AddShell();
|
|
builder.Services.AddRemoteBackend(backendApiConfig);
|
|
builder.Services.AddLoginModule();
|
|
builder.Services.UseElsaIdentity();
|
|
builder.Services.AddDashboardModule();
|
|
builder.Services.AddWorkflowsModule();
|
|
builder.Services.AddAgentsModule(backendApiConfig);
|
|
|
|
// Build the application.
|
|
var app = builder.Build();
|
|
|
|
// Apply client config.
|
|
var js = app.Services.GetRequiredService<IJSRuntime>();
|
|
var clientConfig = await js.InvokeAsync<JsonElement>("getClientConfig");
|
|
var apiUrl = clientConfig.GetProperty("apiUrl").GetString()!;
|
|
app.Services.GetRequiredService<IOptions<BackendOptions>>().Value.Url = new Uri(apiUrl);
|
|
|
|
// Run each startup task.
|
|
var startupTaskRunner = app.Services.GetRequiredService<IStartupTaskRunner>();
|
|
await startupTaskRunner.RunStartupTasksAsync();
|
|
|
|
// Run the application.
|
|
await app.RunAsync(); |