Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.Permissions
Overview
This feature keeps the Eltheon permission catalogue in sync with the Identity database. It exposes an extensible registry for declaring permissions (IPermissionProvider) and a Synchronizer/HostedService pair that ensures the Permissions table always contains the definitions required by the platform or individual templates.
Capabilities
PermissionRegistrymerges permissions from every registeredIPermissionProviderand deduplicates entries by name.PermissionSynchronizercompares the registry with the database viaIPermissionDbContextand inserts missing permissions without touching existing rows.AddPermissionSynchronization<TContext>()wires the synchronizer into DI as a hosted service so each host keeps its permission store up to date on startup.- Static helpers (e.g.,
StaticPermissionProvider) make it trivial for templates to expose their own permission definitions.
Usage
// Program.cs
builder.Services.AddSingleton<IPermissionProvider, PermissionSeedProvider>();
builder.Services.AddPermissionSynchronization<AuthDbContext>();
- Implement
IPermissionProviderin your template/host to expose the permissions you ship (it can reuse the existingPermissionSeedlist). - Ensure your
AuthDbContextimplementsIPermissionDbContextso the synchronizer can accessPermissions/RolePermissions. - Call
AddPermissionSynchronization<TContext>()and the feature takes care of syncing permissions at runtime.
Dependencies
- Requires the Identity feature for the permission entities (
Permission,RolePermission). - The host must provide an EF Core
DbContextthat implementsIPermissionDbContext.
Diagnostics
The hosted service logs when new permissions are inserted (Information) and when the set is already in sync (Debug). Hook Serilog or any other logging provider to the Redeon.SuperSiteEngineCore.Web.Eltheon.Core.Features.Permissions category to trace synchronization events.