Monsterkane05.MulitenantOIDC.Template
1.0.1
dotnet new install Monsterkane05.MulitenantOIDC.Template@1.0.1
C# Multitenant OpenIDConnect Aspire Template
A template for setting up applications which require seperate OIDC providers for each tenant using EF Core with a Postgres Database. It makes use of Finbuckle Multitenant allowing you to customise the tenant resolution strategies. A Blazor admin portal project comes inside of this template which is used to configure each of your tenants.
ApplicationDBContext inside of data should be used for all your data entities using the [MultiTenant] attribute from Finbuckle
This template does not support Blazor applications as of current
Project Template
You will have a project in the following structure:
- Admin
- AppHost
- Data
- Infrastructure
- MigrationService
Supported Identity Providers
The admin portal provides properties for standard OIDC providers. It has been tested with Azure EntraID & Auth0.
Getting Started
Add your admin panel OIDC parameters in the AppHost appsettings.json it should look like
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
},
"Parameters": {
"admin-authority": "---",
"admin-client-id": "---",
"admin-client-secret": "---"
}
}
Add migrations to the infrastructure project by running the following commands:
dotnet ef migrations add --project MTTemplate.Infrastructure\MTTemplate.Infrastructure.csproj --startup-project MTTemplate.Admin\MTTemplate.Admin.csproj --context MTTemplate.Infrastructure.Database.TenantDbContext {MIGRATION NAME} --output-dir TenantMigrations
dotnet ef migrations add --project MTTemplate.Infrastructure\MTTemplate.Infrastructure.csproj --startup-project MTTemplate.Admin\MTTemplate.Admin.csproj --context MTTemplate.Infrastructure.Database.ApplicationDbContext {MIGRATION NAME} --output-dir AppMigrations
Example WebAPI Setup
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();
builder.Services.AddRouting(options =>
{
options.LowercaseUrls = true;
});
builder.Services.AddControllers();
builder.AddMTWebAPIApplication(); //<-- Add This Line
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.UseMTWebAPIApplication(); //<-- Add This Line
app.UseHttpsRedirection();
app.UseAuthentication(); //<-- Add This Line
app.UseAuthorization(); //<-- Add This Line
app.MapControllers();
app.Run();
Example Razor WebApp Setup
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages();
builder.AddMTWebRazorApplication(); //<-- Add This Line
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseMTWebRazorApplication(); //<-- Add This Line
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication(); //<-- Add This Line
app.UseAuthorization(); //<-- Add This Line
app.MapStaticAssets().ExcludeFromMultiTenantResolution();
app.MapRazorPages()
.WithStaticAssets().ExcludeFromMultiTenantResolution();
app.Run();
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.1 | 566 | 10/15/2025 |