| | | 1 | | using AsiBackbone.Core.Metadata; |
| | | 2 | | using AsiBackbone.DependencyInjection; |
| | | 3 | | using Microsoft.Extensions.DependencyInjection; |
| | | 4 | | using Microsoft.Extensions.DependencyInjection.Extensions; |
| | | 5 | | |
| | | 6 | | namespace AsiBackbone.AspNetCore.DependencyInjection; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Provides regulated-governance registration helpers for hosts that want a repeatable, fail-closed ASP.NET Core postur |
| | | 10 | | /// </summary> |
| | | 11 | | public static class AsiBackboneRegulatedGovernanceServiceCollectionExtensions |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// Adds ASP.NET Core endpoint governance, applies the strict governance option profile, and registers the |
| | | 15 | | /// provider-neutral governance metadata sanitation pipeline. |
| | | 16 | | /// </summary> |
| | | 17 | | /// <param name="services">The service collection to configure.</param> |
| | | 18 | | /// <returns>The same service collection so calls can be chained.</returns> |
| | | 19 | | /// <exception cref="ArgumentNullException"> |
| | | 20 | | /// Thrown when <paramref name="services" /> is <see langword="null" />. |
| | | 21 | | /// </exception> |
| | | 22 | | /// <remarks> |
| | | 23 | | /// This helper establishes a conservative governance posture; it is not a legal or regulatory compliance |
| | | 24 | | /// certification. Hosts still own authentication, authorization, policy and threat-model registrations, |
| | | 25 | | /// capability proof verification, durable replay/use tracking, metadata classifiers, durable audit and outbox |
| | | 26 | | /// persistence, managed-key signing, monitoring, retention, and final execution enforcement. |
| | | 27 | | /// </remarks> |
| | | 28 | | public static IServiceCollection AddAsiBackboneRegulatedGovernance(this IServiceCollection services) |
| | | 29 | | { |
| | 4 | 30 | | ArgumentNullException.ThrowIfNull(services); |
| | | 31 | | |
| | 3 | 32 | | _ = services.AddAsiBackboneAspNetCore(); |
| | 3 | 33 | | _ = services.AddAsiBackboneStrictGovernance(); |
| | | 34 | | |
| | 3 | 35 | | services.TryAddScoped<IGovernanceMetadataSanitizer>(serviceProvider => |
| | 6 | 36 | | new DefaultGovernanceMetadataSanitizer( |
| | 6 | 37 | | serviceProvider.GetServices<IGovernanceMetadataClassifier>(), |
| | 6 | 38 | | GovernanceMetadataBudget.Recommended)); |
| | | 39 | | |
| | 3 | 40 | | return services; |
| | | 41 | | } |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Applies the regulated governance profile through the explicit <c>AddAsiBackbone</c> builder facade. |
| | | 45 | | /// </summary> |
| | | 46 | | /// <param name="builder">The AsiBackbone builder facade being configured.</param> |
| | | 47 | | /// <returns>The same builder so calls can be chained.</returns> |
| | | 48 | | /// <exception cref="ArgumentNullException"> |
| | | 49 | | /// Thrown when <paramref name="builder" /> is <see langword="null" />. |
| | | 50 | | /// </exception> |
| | | 51 | | public static IAsiBackboneBuilder UseRegulatedGovernanceProfile(this IAsiBackboneBuilder builder) |
| | | 52 | | { |
| | 1 | 53 | | ArgumentNullException.ThrowIfNull(builder); |
| | | 54 | | |
| | 1 | 55 | | _ = builder.Services.AddAsiBackboneRegulatedGovernance(); |
| | 1 | 56 | | return builder; |
| | | 57 | | } |
| | | 58 | | } |