| | | 1 | | using Elsa.Common.Multitenancy; |
| | | 2 | | using Elsa.Features.Services; |
| | | 3 | | using Elsa.Features.Abstractions; |
| | | 4 | | using Elsa.Connections.Contracts; |
| | | 5 | | using Elsa.Connections.Services; |
| | | 6 | | using Elsa.Features.Attributes; |
| | | 7 | | using Elsa.Secrets.Features; |
| | | 8 | | using Microsoft.Extensions.DependencyInjection; |
| | | 9 | | using Microsoft.Extensions.DependencyInjection.Extensions; |
| | | 10 | | using Microsoft.Extensions.Options; |
| | | 11 | | |
| | | 12 | | namespace Elsa.Connections.Features; |
| | | 13 | | |
| | | 14 | | [DependsOn(typeof(SecretsFeature))] |
| | 212 | 15 | | public sealed class ConnectionsFeature(IModule module) : FeatureBase(module) |
| | | 16 | | { |
| | | 17 | | public override void Apply() |
| | | 18 | | { |
| | | 19 | | // Lifecycle services always establish an explicit tenant context. Keep a default accessor for |
| | | 20 | | // non-multitenant hosts; TryAdd preserves the accessor supplied by MultitenancyFeature when enabled. |
| | 212 | 21 | | Services.TryAddSingleton<ITenantAccessor, DefaultTenantAccessor>(); |
| | 212 | 22 | | Services.TryAddSingleton(TimeProvider.System); |
| | 212 | 23 | | Services.TryAddScoped<IConnectionUseAuthorizer, DenyAllConnectionUseAuthorizer>(); |
| | 212 | 24 | | Services.AddOptions<ConnectionInspectionOptions>(); |
| | | 25 | | // Persistence is optional. An inspector without a lifecycle store stays fail-closed. |
| | 215 | 26 | | Services.TryAddScoped<IConnectionMetadataInspector>(sp => new DefaultConnectionMetadataInspector( |
| | 215 | 27 | | sp.GetService<IConnectionLifecycleStore>(), |
| | 215 | 28 | | sp.GetRequiredService<IConnectionUseAuthorizer>(), |
| | 215 | 29 | | sp.GetRequiredService<ITenantAccessor>(), |
| | 215 | 30 | | sp.GetRequiredService<IOptions<ConnectionInspectionOptions>>())); |
| | 212 | 31 | | Services.TryAddScoped<DefaultConnectionLifecycleService>(); |
| | 325 | 32 | | Services.TryAddScoped<IConnectionLifecycleService>(sp => sp.GetRequiredService<DefaultConnectionLifecycleService |
| | 228 | 33 | | Services.TryAddScoped<IStaticApiKeyLifecycleService>(sp => sp.GetRequiredService<DefaultConnectionLifecycleServi |
| | 217 | 34 | | Services.TryAddScoped<IConnectionBackgroundUseService>(sp => sp.GetRequiredService<DefaultConnectionLifecycleSer |
| | 249 | 35 | | Services.TryAddScoped<IConnectionLifecycleRecoveryService>(sp => sp.GetRequiredService<DefaultConnectionLifecycl |
| | 212 | 36 | | } |
| | | 37 | | } |