feat: Aggiunto sistema crittografia credenziali portabile e migrazione
Sostituita Windows ProtectedData con AES-256-GCM per compatibilità multi-macchina. Aggiunta interfaccia migrazione guidata per credenziali legacy e gestione errori completa. - Nuovo: Servizio crittografia AES con derivazione chiavi PBKDF2 - Nuovo: Interfaccia Blazor migrazione con rilevamento credenziali - Nuovo: Documentazione utente per risoluzione problemi - Fix: Errori compilazione e problemi binding componenti - Miglioramento: Credenziali portabili funzionano su qualsiasi macchina dopo migrazione una-tantum Completamente retrocompatibile - credenziali
This commit is contained in:
@@ -6,11 +6,34 @@
|
||||
@using Microsoft.JSInterop
|
||||
@inject IDataConnectionCredentialService CredentialService
|
||||
@inject IJSRuntime JSRuntime
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<PageTitle>Gestione Credenziali</PageTitle>
|
||||
|
||||
<h3>Gestione Credenziali</h3>
|
||||
|
||||
@* Controllo per credenziali problematiche *@
|
||||
@if (hasProblematicCredentials && !loading)
|
||||
{
|
||||
<div class="alert alert-warning mb-4" role="alert">
|
||||
<h4 class="alert-heading"><i class="oi oi-warning"></i> Attenzione!</h4>
|
||||
<p>
|
||||
Sono state rilevate credenziali che non possono essere decrittografate.
|
||||
Questo può accadere quando l'applicazione viene eseguita su una macchina o con un utente diverso
|
||||
da quello utilizzato per creare le credenziali.
|
||||
</p>
|
||||
<hr>
|
||||
<p class="mb-0">
|
||||
<button class="btn btn-warning" @onclick="@(() => Navigation.NavigateTo("/credential-migration"))">
|
||||
<i class="oi oi-wrench"></i> Risolvi Problema Credenziali
|
||||
</button>
|
||||
<button class="btn btn-outline-warning ms-2" @onclick="CheckForProblematicCredentials">
|
||||
<i class="oi oi-reload"></i> Verifica Nuovamente
|
||||
</button>
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<div class="btn-group" role="group">
|
||||
@@ -519,6 +542,7 @@ else
|
||||
private bool loading = true;
|
||||
private string? errorMessage = null;
|
||||
private bool testingConnection = false;
|
||||
private bool hasProblematicCredentials = false;
|
||||
|
||||
// Modal state
|
||||
private bool showDatabaseModal = false;
|
||||
@@ -529,16 +553,16 @@ else
|
||||
private RestApiCredential currentRestApiCredential = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await RefreshCredentials();
|
||||
{ await RefreshCredentials();
|
||||
CheckForProblematicCredentials();
|
||||
} private async Task RefreshCredentials()
|
||||
{
|
||||
loading = true;
|
||||
errorMessage = null;
|
||||
try
|
||||
{
|
||||
databaseCredentials = await CredentialService.GetAllDatabaseCredentialsAsync();
|
||||
{ databaseCredentials = await CredentialService.GetAllDatabaseCredentialsAsync();
|
||||
restApiCredentials = await CredentialService.GetAllRestApiCredentialsAsync();
|
||||
CheckForProblematicCredentials();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -957,6 +981,56 @@ else
|
||||
};
|
||||
|
||||
return IsFieldRequired(fieldName, serviceType) ? $"{label} *" : label;
|
||||
} /// <summary>
|
||||
/// Verifica se ci sono credenziali che non possono essere decrittografate
|
||||
/// </summary>
|
||||
private void CheckForProblematicCredentials()
|
||||
{
|
||||
try
|
||||
{
|
||||
hasProblematicCredentials = false;
|
||||
|
||||
// Verifica credenziali database
|
||||
foreach (var dbCred in databaseCredentials)
|
||||
{
|
||||
if (HasProblematicPassword(dbCred.Password))
|
||||
{
|
||||
hasProblematicCredentials = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Verifica credenziali REST API se non trovate problematiche
|
||||
if (!hasProblematicCredentials)
|
||||
{
|
||||
foreach (var restCred in restApiCredentials)
|
||||
{
|
||||
if (HasProblematicPassword(restCred.Password) ||
|
||||
HasProblematicPassword(restCred.ApiKey) ||
|
||||
HasProblematicPassword(restCred.AuthToken) ||
|
||||
HasProblematicPassword(restCred.ClientSecret))
|
||||
{
|
||||
hasProblematicCredentials = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Log dell'errore, ma non bloccare l'interfaccia
|
||||
Console.WriteLine($"Errore nella verifica delle credenziali problematiche: {ex.Message}");
|
||||
}
|
||||
} /// <summary>
|
||||
/// Verifica se una password indica un problema di decrittografia
|
||||
/// </summary>
|
||||
private bool HasProblematicPassword(string? password)
|
||||
{
|
||||
return !string.IsNullOrEmpty(password) &&
|
||||
(password.Contains("*** CREDENZIALI NON DISPONIBILI") ||
|
||||
password.Contains("*** ERRORE DECRITTOGRAFIA ***"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user