Class PermissionAutoSeedHostedService
- Namespace
- KadicAuth.Application.Permissions.Seeding
- Assembly
- KadicAuth.Application.dll
Runs once at application startup and seeds every permission declared in
KadicErp.Core.Abstractions.Authorization.Permissions that is not yet
in the database. New permissions are automatically assigned to all active
roles (and tenant roles, except platform-scoped codes) by the existing
SeedPermissionsCommand handler.
The seeder is idempotent. Existing permissions are skipped. It groups
entries by module so that a missing module (unmapped / not yet provisioned
in Auth.Modules) does not abort the whole sweep.
Controlled by Permissions:AutoSeedOnStartup (default: true).
Set to false in appsettings to disable (e.g. read-only envs).
public sealed class PermissionAutoSeedHostedService
- Inheritance
-
objectPermissionAutoSeedHostedService
Constructors
PermissionAutoSeedHostedService(IServiceProvider, IConfiguration, ILogger<PermissionAutoSeedHostedService>)
public PermissionAutoSeedHostedService(IServiceProvider serviceProvider, IConfiguration configuration, ILogger<PermissionAutoSeedHostedService> logger)
Parameters
serviceProviderIServiceProviderconfigurationIConfigurationloggerILogger<PermissionAutoSeedHostedService>
Methods
StartAsync(CancellationToken)
Triggered when the application host is ready to start the service.
public Task StartAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenIndicates that the start process has been aborted.
Returns
- Task
A System.Threading.Tasks.Task that represents the asynchronous Start operation.
StopAsync(CancellationToken)
Triggered when the application host is performing a graceful shutdown.
public Task StopAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenIndicates that the shutdown process should no longer be graceful.
Returns
- Task
A System.Threading.Tasks.Task that represents the asynchronous Stop operation.