@page "/appsettings/json" @using Indotalent.Infrastructure.Authentication.Firebase @using Indotalent.Infrastructure.Authentication.Keycloak @using Microsoft.AspNetCore.Authorization @using Indotalent.Infrastructure.Authorization.Identity @attribute [Authorize(Roles = ApplicationRoles.Admin)] @using Indotalent.Infrastructure.Authentication.Identity @using Indotalent.Infrastructure.Database @using Indotalent.Infrastructure.BackgroundJob @using Indotalent.Infrastructure.Email @using Indotalent.Infrastructure.File @using Indotalent.Infrastructure.Logging @using Indotalent.Infrastructure.Authentication @using MudBlazor @using System.Reflection @inject IdentityService IdentitySvc @inject DatabaseService DbSvc @inject BackgroundJobService JobSvc @inject EmailService EmailSvc @inject FileStorageService StorageSvc @inject LoggingService LogSvc @inject FirebaseService FirebaseSvc @inject KeycloakService KeycloakSvc
@RenderIdentityProperties(IdentitySvc.GetConfiguration(), "Security & Identity") @RenderObjectProperties(DbSvc.GetConfiguration(), "Database Engine") @RenderObjectProperties(JobSvc.GetConfiguration(), "Background Job Services") @RenderObjectProperties(EmailSvc.GetConfiguration(), "Email Providers") @RenderObjectProperties(StorageSvc.GetConfiguration(), "File Storage Systems") @RenderObjectProperties(LogSvc.GetConfiguration(), "Diagnostic Logging")
@code { private RenderFragment RenderIdentityProperties(IdentitySettingsModel settings, string sectionTitle) { return __builder => {
@sectionTitle Security Policy & Default Credentials
/ System / @sectionTitle
if (settings != null) { @RenderSectionCard("Password Policy", settings.Password) @RenderSectionCard("Cookie Settings", settings.Cookies) @RenderSectionCard("Default Admin", settings.DefaultAdmin) @RenderSectionCard("SignIn Policy", settings.SignIn) @RenderSectionCard("SSO Firebase", settings.SsoFirebase) @RenderSectionCard("SSO Keycloak", settings.SsoKeycloak) } }; } private RenderFragment RenderSectionCard(string title, object sectionValue) { return __builder => { if (sectionValue == null) return;
@title CONFIGURED
@{ var props = sectionValue.GetType().GetProperties(); int i = 0; } @foreach (var p in props) { var val = p.GetValue(sectionValue);
@p.Name
@(MaskIfSensitive(p.Name, val?.ToString()))
}
}; } private RenderFragment RenderObjectProperties(object settingsObj, string sectionTitle) { return __builder => {
@sectionTitle Configuration discovery (Full Inspection Mode)
/ System / @sectionTitle
if (settingsObj != null) { var providers = settingsObj.GetType().GetProperties(); foreach (var provider in providers) { var providerValue = provider.GetValue(settingsObj); if (providerValue == null) continue;
@provider.Name @{ var isUsedProp = providerValue.GetType().GetProperty("IsUsed"); bool isUsed = (bool)(isUsedProp?.GetValue(providerValue) ?? false); } @(isUsed ? "ACTIVE" : "DISABLED")
@{ var props = providerValue.GetType().GetProperties(); int i = 0; } @foreach (var p in props) { if (p.Name == "IsUsed") continue;
@p.Name
@(MaskIfSensitive(p.Name, p.GetValue(providerValue)?.ToString()))
}
} } }; } private string MaskIfSensitive(string propertyName, string value) { if (string.IsNullOrEmpty(value)) return "-"; var sensitiveKeys = new[] { "Password", "Secret", "Key", "Token", "ApiKey" }; if (sensitiveKeys.Any(k => propertyName.Contains(k, StringComparison.OrdinalIgnoreCase))) { return "•••••••••••••••• (Encrypted)"; } return value; } }