mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
Add logging to tokenables (#2298)
* Add logging to token usages * Add settings manipulation of log levels * Maintain no logging for dev * Log exception causing Token failure in TryUnprotect * dotnet format 🤖 * Added deconstruction operator on new debug logs. * Split off log level settings into separate files * Improve log messages * dotnet format 🤖 * Fix token serialization * Final review notes Co-authored-by: Todd Martin <>
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
namespace Bit.Core.Settings;
|
||||
using Bit.Core.Settings.LoggingSettings;
|
||||
|
||||
namespace Bit.Core.Settings;
|
||||
|
||||
public class GlobalSettings : IGlobalSettings
|
||||
{
|
||||
@ -58,6 +60,7 @@ public class GlobalSettings : IGlobalSettings
|
||||
public virtual DocumentDbSettings DocumentDb { get; set; } = new DocumentDbSettings();
|
||||
public virtual SentrySettings Sentry { get; set; } = new SentrySettings();
|
||||
public virtual SyslogSettings Syslog { get; set; } = new SyslogSettings();
|
||||
public virtual ILogLevelSettings MinLogLevel { get; set; } = new LogLevelSettings();
|
||||
public virtual NotificationHubSettings NotificationHub { get; set; } = new NotificationHubSettings();
|
||||
public virtual YubicoSettings Yubico { get; set; } = new YubicoSettings();
|
||||
public virtual DuoSettings Duo { get; set; } = new DuoSettings();
|
||||
|
@ -15,5 +15,6 @@ public interface IGlobalSettings
|
||||
IBaseServiceUriSettings BaseServiceUri { get; set; }
|
||||
ITwoFactorAuthSettings TwoFactorAuth { get; set; }
|
||||
ISsoSettings Sso { get; set; }
|
||||
ILogLevelSettings MinLogLevel { get; set; }
|
||||
IPasswordlessAuthSettings PasswordlessAuth { get; set; }
|
||||
}
|
||||
|
74
src/Core/Settings/ILogLevelSettings.cs
Normal file
74
src/Core/Settings/ILogLevelSettings.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Core.Settings;
|
||||
|
||||
public interface ILogLevelSettings
|
||||
{
|
||||
IBillingLogLevelSettings BillingSettings { get; set; }
|
||||
IApiLogLevelSettings ApiSettings { get; set; }
|
||||
IIdentityLogLevelSettings IdentitySettings { get; set; }
|
||||
IScimLogLevelSettings ScimSettings { get; set; }
|
||||
ISsoLogLevelSettings SsoSettings { get; set; }
|
||||
IAdminLogLevelSettings AdminSettings { get; set; }
|
||||
IEventsLogLevelSettings EventsSettings { get; set; }
|
||||
IEventsProcessorLogLevelSettings EventsProcessorSettings { get; set; }
|
||||
IIconsLogLevelSettings IconsSettings { get; set; }
|
||||
INotificationsLogLevelSettings NotificationsSettings { get; set; }
|
||||
}
|
||||
|
||||
public interface IBillingLogLevelSettings
|
||||
{
|
||||
LogEventLevel Default { get; set; }
|
||||
LogEventLevel Jobs { get; set; }
|
||||
}
|
||||
|
||||
public interface IApiLogLevelSettings
|
||||
{
|
||||
LogEventLevel Default { get; set; }
|
||||
LogEventLevel IdentityToken { get; set; }
|
||||
LogEventLevel IpRateLimit { get; set; }
|
||||
}
|
||||
|
||||
public interface IIdentityLogLevelSettings
|
||||
{
|
||||
LogEventLevel Default { get; set; }
|
||||
LogEventLevel IdentityToken { get; set; }
|
||||
LogEventLevel IpRateLimit { get; set; }
|
||||
}
|
||||
|
||||
public interface IScimLogLevelSettings
|
||||
{
|
||||
LogEventLevel Default { get; set; }
|
||||
}
|
||||
|
||||
public interface ISsoLogLevelSettings
|
||||
{
|
||||
LogEventLevel Default { get; set; }
|
||||
}
|
||||
|
||||
public interface IAdminLogLevelSettings
|
||||
{
|
||||
LogEventLevel Default { get; set; }
|
||||
}
|
||||
|
||||
public interface IEventsLogLevelSettings
|
||||
{
|
||||
LogEventLevel Default { get; set; }
|
||||
LogEventLevel IdentityToken { get; set; }
|
||||
}
|
||||
|
||||
public interface IEventsProcessorLogLevelSettings
|
||||
{
|
||||
LogEventLevel Default { get; set; }
|
||||
}
|
||||
|
||||
public interface IIconsLogLevelSettings
|
||||
{
|
||||
LogEventLevel Default { get; set; }
|
||||
}
|
||||
|
||||
public interface INotificationsLogLevelSettings
|
||||
{
|
||||
LogEventLevel Default { get; set; }
|
||||
LogEventLevel IdentityToken { get; set; }
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Core.Settings.LoggingSettings;
|
||||
|
||||
public class AdminLogLevelSettings : IAdminLogLevelSettings
|
||||
{
|
||||
public LogEventLevel Default { get; set; } = LogEventLevel.Error;
|
||||
}
|
10
src/Core/Settings/LoggingSettings/ApiLogLevelSettings.cs
Normal file
10
src/Core/Settings/LoggingSettings/ApiLogLevelSettings.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Core.Settings.LoggingSettings;
|
||||
|
||||
public class ApiLogLevelSettings : IApiLogLevelSettings
|
||||
{
|
||||
public LogEventLevel Default { get; set; } = LogEventLevel.Error;
|
||||
public LogEventLevel IdentityToken { get; set; } = LogEventLevel.Fatal;
|
||||
public LogEventLevel IpRateLimit { get; set; } = LogEventLevel.Information;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Core.Settings.LoggingSettings;
|
||||
|
||||
public class BillingLogLevelSettings : IBillingLogLevelSettings
|
||||
{
|
||||
public LogEventLevel Default { get; set; } = LogEventLevel.Warning;
|
||||
public LogEventLevel Jobs { get; set; } = LogEventLevel.Information;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Core.Settings.LoggingSettings;
|
||||
|
||||
public class EventsLogLevelSettings : IEventsLogLevelSettings
|
||||
{
|
||||
public LogEventLevel Default { get; set; } = LogEventLevel.Error;
|
||||
public LogEventLevel IdentityToken { get; set; } = LogEventLevel.Fatal;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Core.Settings.LoggingSettings;
|
||||
|
||||
public class EventsProcessorLogLevelSettings : IEventsProcessorLogLevelSettings
|
||||
{
|
||||
public LogEventLevel Default { get; set; } = LogEventLevel.Warning;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Core.Settings.LoggingSettings;
|
||||
|
||||
public class IconsLogLevelSettings : IIconsLogLevelSettings
|
||||
{
|
||||
public LogEventLevel Default { get; set; } = LogEventLevel.Error;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Core.Settings.LoggingSettings;
|
||||
|
||||
public class IdentityLogLevelSettings : IIdentityLogLevelSettings
|
||||
{
|
||||
public LogEventLevel Default { get; set; } = LogEventLevel.Error;
|
||||
public LogEventLevel IdentityToken { get; set; } = LogEventLevel.Fatal;
|
||||
public LogEventLevel IpRateLimit { get; set; } = LogEventLevel.Information;
|
||||
}
|
16
src/Core/Settings/LoggingSettings/LogLevelSettings.cs
Normal file
16
src/Core/Settings/LoggingSettings/LogLevelSettings.cs
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
namespace Bit.Core.Settings.LoggingSettings;
|
||||
|
||||
public class LogLevelSettings : ILogLevelSettings
|
||||
{
|
||||
public IBillingLogLevelSettings BillingSettings { get; set; } = new BillingLogLevelSettings();
|
||||
public IApiLogLevelSettings ApiSettings { get; set; } = new ApiLogLevelSettings();
|
||||
public IIdentityLogLevelSettings IdentitySettings { get; set; } = new IdentityLogLevelSettings();
|
||||
public IScimLogLevelSettings ScimSettings { get; set; } = new ScimLogLevelSettings();
|
||||
public ISsoLogLevelSettings SsoSettings { get; set; } = new SsoLogLevelSettings();
|
||||
public IAdminLogLevelSettings AdminSettings { get; set; } = new AdminLogLevelSettings();
|
||||
public IEventsLogLevelSettings EventsSettings { get; set; } = new EventsLogLevelSettings();
|
||||
public IEventsProcessorLogLevelSettings EventsProcessorSettings { get; set; } = new EventsProcessorLogLevelSettings();
|
||||
public IIconsLogLevelSettings IconsSettings { get; set; } = new IconsLogLevelSettings();
|
||||
public INotificationsLogLevelSettings NotificationsSettings { get; set; } = new NotificationsLogLevelSettings();
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Core.Settings.LoggingSettings;
|
||||
|
||||
public class NotificationsLogLevelSettings : INotificationsLogLevelSettings
|
||||
{
|
||||
public LogEventLevel Default { get; set; } = LogEventLevel.Warning;
|
||||
public LogEventLevel IdentityToken { get; set; } = LogEventLevel.Fatal;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Core.Settings.LoggingSettings;
|
||||
|
||||
public class ScimLogLevelSettings : IScimLogLevelSettings
|
||||
{
|
||||
public LogEventLevel Default { get; set; } = LogEventLevel.Warning;
|
||||
}
|
8
src/Core/Settings/LoggingSettings/SsoLogLevelSettings.cs
Normal file
8
src/Core/Settings/LoggingSettings/SsoLogLevelSettings.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Core.Settings.LoggingSettings;
|
||||
|
||||
public class SsoLogLevelSettings : ISsoLogLevelSettings
|
||||
{
|
||||
public LogEventLevel Default { get; set; } = LogEventLevel.Error;
|
||||
}
|
Reference in New Issue
Block a user