Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Do not log dataprotection warnings to database log but keep for filelog (#493)

Leendert de Borstc3c85bc10eba
diff --git a/src/Utilities/AliasVault.Logging/LoggingConfiguration.cs b/src/Utilities/AliasVault.Logging/LoggingConfiguration.cs
index f108e5e86..4752ef149 100644
--- a/src/Utilities/AliasVault.Logging/LoggingConfiguration.cs
+++ b/src/Utilities/AliasVault.Logging/LoggingConfiguration.cs
@@ -56,11 +56,15 @@ public static class LoggingConfiguration
rollingInterval: RollingInterval.Day,
outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {SourceContext} {Message:lj} {Properties:j}{NewLine}{Exception}"))
- // Log all warning and above to database via EF core except for Microsoft.EntityFrameworkCore logs
- // as this would create a loop.
+ // Log all warning and above to database via EF core except for:
+ // - Microsoft.EntityFrameworkCore logsas this would create a loop.
+ // - Microsoft.AspNetCore.Antiforgery logs
+ // - Microsoft.AspNetCore.DataProtection logs
.WriteTo.Logger(lc => lc
.Filter.ByIncludingOnly(evt => evt.Level >= LogEventLevel.Warning)
.Filter.ByExcluding(Matching.FromSource("Microsoft.EntityFrameworkCore"))
+ .Filter.ByExcluding(Matching.FromSource("Microsoft.AspNetCore.Antiforgery"))
+ .Filter.ByExcluding(Matching.FromSource("Microsoft.AspNetCore.DataProtection"))
.WriteTo.Sink(new DatabaseSink(CultureInfo.InvariantCulture, () => services.BuildServiceProvider().GetRequiredService<IDbContextFactory<AliasServerDbContext>>(), applicationName)))
.CreateLogger());
diff --git a/src/Utilities/Cryptography/AliasVault.Cryptography.Server/DataProtectionExtensions.cs b/src/Utilities/Cryptography/AliasVault.Cryptography.Server/DataProtectionExtensions.cs
index eeb615fe7..bca3f18bc 100644
--- a/src/Utilities/Cryptography/AliasVault.Cryptography.Server/DataProtectionExtensions.cs
+++ b/src/Utilities/Cryptography/AliasVault.Cryptography.Server/DataProtectionExtensions.cs
@@ -52,8 +52,8 @@ public static class DataProtectionExtensions
}
services.AddDataProtection()
- .ProtectKeysWithCertificate(cert)
.PersistKeysToDbContext<AliasServerDbContext>()
+ .ProtectKeysWithCertificate(cert)
.SetApplicationName(applicationName);
return services;