Enhanced logging & error handling for auth and pg backups

- Add detailed debug/warning logs to authentication flows (AuthService, AuthorizationContext, WebSocketManager) for better traceability of auth attempts and failures.
- Log WebSocket authentication attempts, including IP, path, and token preview.
- Introduce PostgresVersionMismatchException for pg_dump/pg_restore version mismatches; parse and log server/client versions, clean up failed backups, and provide upgrade guidance.
- Add helper for parsing version mismatch errors.
- Update using directives and minor code cleanups.
- Update .csproj.user with new publish profile path.
This commit is contained in:
2026-03-04 12:37:39 -05:00
parent 895372fe98
commit 667c3768a9
8 changed files with 197 additions and 3 deletions
@@ -40,9 +40,23 @@ namespace Emby.Server.Implementations.HttpServer
/// <inheritdoc />
public async Task WebSocketRequestHandler(HttpContext context)
{
_logger.LogDebug(
"WebSocket authentication attempt from {IP}, Path: {Path}, QueryString: {QueryString}",
context.Connection.RemoteIpAddress,
context.Request.Path,
context.Request.QueryString);
var authorizationInfo = await _authService.Authenticate(context.Request).ConfigureAwait(false);
if (!authorizationInfo.IsAuthenticated)
{
var tokenPreview = authorizationInfo.HasToken && authorizationInfo.Token?.Length > 8
? authorizationInfo.Token.Substring(0, 8) + "..."
: authorizationInfo.Token ?? "null";
_logger.LogDebug(
"WebSocket authentication failed from {IP}. HasToken: {HasToken}, Token: {Token}",
context.Connection.RemoteIpAddress,
authorizationInfo.HasToken,
tokenPreview);
throw new SecurityException("Token is required");
}