Class InfrastructureSecurityServiceCollectionExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- Stratara.Infrastructure.dll
Service-collection extensions for the Stratara security primitives (secure JSON serializer + blob encryption + key store).
public static class InfrastructureSecurityServiceCollectionExtensions
- Inheritance
-
InfrastructureSecurityServiceCollectionExtensions
- Inherited Members
Methods
AddSecurity(IServiceCollection)
Registers Stratara's security stack: ISecureJsonSerializer, the AES-GCM blob
encryptor and IEncryptionFactory (delegated to Stratara.Security), and a
development-only IKeyStore fallback (DummyKeyStore).
public static IServiceCollection AddSecurity(this IServiceCollection services)
Parameters
servicesIServiceCollectionThe service collection.
Returns
- IServiceCollection
The same service collection for chaining.
Examples
Register a production key store first — the fallback this call adds uses TryAdd, so
whichever key store is registered before it wins:
services.AddStrataraFileKeyStore(configuration);
services.AddSecurity();
Remarks
The IKeyStore registration uses TryAddSingleton so a production key store
registered first — e.g. AddStrataraFileKeyStore(configuration) from
Stratara.Security, or an HSM / Key Vault / KMS implementation — takes precedence.
Production hosts MUST register a real IKeyStore before calling this method. The fallback DummyKeyStore throws on construction outside the Development environment to prevent accidental deployment of the test key.