Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Orbis25/FoundationKit/llms.txt
Use this file to discover all available pages before exploring further.
FoundationKitExtensions is a static class in the FoundationKit.Extensions namespace that exposes a set of IServiceCollection extension methods for bootstrapping FoundationKit features. Each method wires up a specific subset of functionality — AutoMapper profiles, ASP.NET Core Identity, or the encryption service — so you only register what your application actually needs.
AddFoundationKit
Registers AutoMapper by scanning the provided assembly forProfile subclasses. This is the minimal setup required to use FoundationKit’s mapping conventions.
IServiceCollection (fluent).
The application’s service collection, typically accessed as
builder.Services.The assembly that will be scanned for AutoMapper
Profile classes. Pass Assembly.GetExecutingAssembly() to scan the entry-point project.AddFoundationKitIdentityWithMapper<T, TDbContext>
Registers AutoMapper and the full ASP.NET Core Identity stack. Use this overload when your application uses bothMapRepository (which depends on AutoMapper) and Identity-based authentication.
services.AddAutoMapper(assembly)— scans the given assembly forProfileclasses.services.AddIdentity<T, IdentityRole>()— registers the core identity services..AddRoles<IdentityRole>()— enables role support..AddEntityFrameworkStores<TDbContext>()— wires EF Core persistence..AddSignInManager<SignInManager<T>>()— registers the sign-in manager..AddDefaultTokenProviders()— adds email/phone/authenticator token providers.
IServiceCollection (fluent).
The application’s service collection.
The assembly scanned for AutoMapper
Profile classes.Your application’s user entity, which must extend
Microsoft.AspNetCore.Identity.IdentityUser.Your EF Core database context, which must extend
Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<T>.AddFoundationKitIdentity<T, TDbContext>
Registers ASP.NET Core Identity without AutoMapper. Choose this overload when your application does not useMapRepository or otherwise manages its own mapping, but still requires Identity-based authentication and authorization.
AddFoundationKitIdentityWithMapper (roles, EF Core stores, SignInManager, and default token providers) but omits the AddAutoMapper call.
Returns IServiceCollection (fluent).
The application’s service collection.
Your application’s user entity.
Your EF Core database context.
AddFoundationKitEncryptor
RegistersIEncryptorService (backed by EncryptorService) along with an EncryptorOption instance that carries the asymmetric key pair and AES header name. IEncryptorService itself is always registered as scoped; the EncryptorOption registration respects the lifetime parameter.
IServiceCollection (fluent).
The application’s service collection.
Configuration object that holds the TweetNaCl key pair, optional text encoding, and the AES header name. See field descriptions below.
Controls how the
EncryptorOption instance is registered. Accepted values: Singleton (default), Transient, or Scoped. IEncryptorService itself is always registered as scoped regardless of this value.EncryptorOption fields
Base64-encoded Curve25519 private key used for TweetNaCl asymmetric encryption and decryption. Can be overridden per-call via the
pvKey parameter on EncryptCore/DecryptCore.Base64-encoded Curve25519 public key. Can be overridden per-call via the
pbKey parameter.Text encoding used when converting serialized JSON to/from bytes. Defaults to
Encoding.UTF8 when null.The HTTP request-header name that carries the per-request AES configuration (key + IV), itself encrypted with the asymmetric key pair. For example
"x-aes-config". Required if you use AesOk or FoundationKitAesEncryptorMiddleware.TryAddSingleton / TryAddTransient / TryAddScoped are used internally, so calling AddFoundationKitEncryptor multiple times will not overwrite an already-registered EncryptorOption.UseFoundationKitApiHandlers
An extension onWebApplication that auto-discovers and maps all minimal-API endpoint groups defined in the given assembly. Call this in Program.cs after var app = builder.Build().
WebApplication instance (fluent).
The built
WebApplication instance.The assembly scanned for concrete, non-abstract, non-generic classes that implement
IEndpointRouteHandler and have a public parameterless constructor.IEndpointRouteHandler
Implement this interface to define a group of minimal-API endpoints that FoundationKit will register automatically.MapEndpoints (IEndpointRouteBuilder)
The lower-level extension thatUseFoundationKitApiHandlers delegates to. Can be called directly on any IEndpointRouteBuilder — useful when you want to scope endpoint registration inside a route group.
Any endpoint route builder, including a
RouteGroupBuilder returned by app.MapGroup(...).The assembly scanned for
IEndpointRouteHandler implementations.IEndpointRouteHandler, instantiates each one with Activator.CreateInstance, and calls MapEndpoints(app) on the instance.