From c9cbf3a5fb733805518552772fc897992d623a89 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Mon, 3 Nov 2025 16:50:38 +0100 Subject: [PATCH 01/18] test --- Ticky.Web/Components/Pages/BoardView.razor | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index 6d5ecfa..e93bfec 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -178,6 +178,8 @@ var httpContext = _httpContextAccessor.HttpContext; + _logger.LogInformation("Connecting to hub at {HubUrl}", _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB)); + _hubConnection = new HubConnectionBuilder() .WithUrl(_navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB), options => { From 1480e8c0e14cfc9728c742c2a760100a1ef65be8 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Mon, 3 Nov 2025 17:03:17 +0100 Subject: [PATCH 02/18] use base_url for hub connection --- Ticky.Web/Components/Pages/BoardView.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index e93bfec..afc27a9 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -181,7 +181,7 @@ _logger.LogInformation("Connecting to hub at {HubUrl}", _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB)); _hubConnection = new HubConnectionBuilder() - .WithUrl(_navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB), options => + .WithUrl(Path.Combine($"{Constants.BASE_URL}/{Constants.Hubs.UPDATE_HUB}"), options => { if(httpContext?.Request.Cookies is not null) { From de9e11d879b7d5b4d45544dd215f35bfd1164867 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Mon, 3 Nov 2025 17:09:01 +0100 Subject: [PATCH 03/18] log same --- Ticky.Web/Components/Pages/BoardView.razor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index afc27a9..7a31b3d 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -178,7 +178,7 @@ var httpContext = _httpContextAccessor.HttpContext; - _logger.LogInformation("Connecting to hub at {HubUrl}", _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB)); + _logger.LogInformation("Connecting to hub at {HubUrl}", Path.Combine($"{Constants.BASE_URL}/{Constants.Hubs.UPDATE_HUB}")); _hubConnection = new HubConnectionBuilder() .WithUrl(Path.Combine($"{Constants.BASE_URL}/{Constants.Hubs.UPDATE_HUB}"), options => From f54d56923f36e79bf0110a9783db024f0300f087 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Mon, 3 Nov 2025 17:11:57 +0100 Subject: [PATCH 04/18] ah shit --- Ticky.Web/Components/Pages/BoardView.razor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index 7a31b3d..b7e59ee 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -178,10 +178,10 @@ var httpContext = _httpContextAccessor.HttpContext; - _logger.LogInformation("Connecting to hub at {HubUrl}", Path.Combine($"{Constants.BASE_URL}/{Constants.Hubs.UPDATE_HUB}")); + _logger.LogInformation("Connecting to hub at {HubUrl}", Path.Combine($"{Constants.BASE_URL}{Constants.Hubs.UPDATE_HUB}")); _hubConnection = new HubConnectionBuilder() - .WithUrl(Path.Combine($"{Constants.BASE_URL}/{Constants.Hubs.UPDATE_HUB}"), options => + .WithUrl(Path.Combine($"{Constants.BASE_URL}{Constants.Hubs.UPDATE_HUB}"), options => { if(httpContext?.Request.Cookies is not null) { From f8579520e9734e437c271debbae2c94fe9eb4d09 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Mon, 3 Nov 2025 17:21:27 +0100 Subject: [PATCH 05/18] test --- Ticky.Web/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ticky.Web/Program.cs b/Ticky.Web/Program.cs index 1247a2f..5654980 100644 --- a/Ticky.Web/Program.cs +++ b/Ticky.Web/Program.cs @@ -155,7 +155,7 @@ mailKitOptions is null builder.Services.AddControllers(); -// builder.WebHost.UseUrls("https://0.0.0.0:7225"); +builder.WebHost.UseUrls("http://0.0.0.0:8080"); var app = builder.Build(); From 0b8b27803e4a8fa762a8e18ffc6c492c7682af0d Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Mon, 3 Nov 2025 17:21:53 +0100 Subject: [PATCH 06/18] test --- Ticky.Web/Program.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Ticky.Web/Program.cs b/Ticky.Web/Program.cs index 5654980..98befe7 100644 --- a/Ticky.Web/Program.cs +++ b/Ticky.Web/Program.cs @@ -155,7 +155,9 @@ mailKitOptions is null builder.Services.AddControllers(); +#if !DEBUG builder.WebHost.UseUrls("http://0.0.0.0:8080"); +#endif var app = builder.Build(); From 324638372cb055a71dd6c20589dd3d7f70c98c5a Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Tue, 18 Nov 2025 16:28:16 +0100 Subject: [PATCH 07/18] test --- Ticky.Web/Components/Pages/BoardView.razor | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index b7e59ee..bfc55a9 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -178,12 +178,14 @@ var httpContext = _httpContextAccessor.HttpContext; - _logger.LogInformation("Connecting to hub at {HubUrl}", Path.Combine($"{Constants.BASE_URL}{Constants.Hubs.UPDATE_HUB}")); + var hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); + + _logger.LogInformation("Connecting to hub at {HubUrl}", hubUri); _hubConnection = new HubConnectionBuilder() - .WithUrl(Path.Combine($"{Constants.BASE_URL}{Constants.Hubs.UPDATE_HUB}"), options => + .WithUrl(hubUri, options => { - if(httpContext?.Request.Cookies is not null) + if (httpContext?.Request.Cookies is not null) { foreach (var cookie in httpContext.Request.Cookies) { @@ -191,7 +193,7 @@ { Name = cookie.Key, Value = cookie.Value, - Domain = new Uri(_navigationManager.BaseUri).Host + Domain = hubUri.Host }); } } From d200dc84b96ee96d4136d0bb0db62d7d5da2b707 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:39:47 +0100 Subject: [PATCH 08/18] test --- Ticky.Web/Components/Pages/BoardView.razor | 44 +++++++++++++++------- Ticky.Web/Program.cs | 25 ++++++++++++ 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index bfc55a9..10b697c 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -1,5 +1,7 @@ @page "/boards/{Id:int}/{CardId:int?}" @using System.Security.Cryptography +@using System.IO +@using System.Runtime.InteropServices @inject NavigationManager _navigationManager @inject IDbContextFactory _dbContextFactory @inject ProtectedLocalStorage _protectedLocalStorage @@ -178,26 +180,42 @@ var httpContext = _httpContextAccessor.HttpContext; - var hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); - - _logger.LogInformation("Connecting to hub at {HubUrl}", hubUri); + Uri hubUri; + try + { + var runningInDocker = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists("/.dockerenv"); + if (runningInDocker) + { + hubUri = new Uri(new Uri("http://localhost:8080"), Constants.Hubs.UPDATE_HUB); + _logger.LogInformation("Detected Docker container. Connecting to hub at {HubUrl}", hubUri); + } + else + { + hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); + _logger.LogInformation("Connecting to hub at {HubUrl}", hubUri); + } + } + catch (Exception ex) + { + _logger.LogWarning(ex, "Failed to determine runtime environment for hub URL; falling back to NavigationManager."); + hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); + } _hubConnection = new HubConnectionBuilder() .WithUrl(hubUri, options => - { - if (httpContext?.Request.Cookies is not null) { - foreach (var cookie in httpContext.Request.Cookies) + if (httpContext?.Request.Cookies is not null) { - options.Cookies.Add(new System.Net.Cookie + foreach (var cookie in httpContext.Request.Cookies) { - Name = cookie.Key, - Value = cookie.Value, - Domain = hubUri.Host - }); + options.Cookies.Add(new System.Net.Cookie + { + Name = cookie.Key, + Value = cookie.Value + }); + } } - } - }) + }) .WithAutomaticReconnect() .Build(); diff --git a/Ticky.Web/Program.cs b/Ticky.Web/Program.cs index 98befe7..954ac61 100644 --- a/Ticky.Web/Program.cs +++ b/Ticky.Web/Program.cs @@ -60,6 +60,31 @@ options.Cookie.SameSite = SameSiteMode.Lax; options.Cookie.HttpOnly = true; options.Cookie.IsEssential = true; + options.Events ??= new Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents(); + options.Events.OnRedirectToLogin = context => + { + var path = context.Request.Path; + if (path.StartsWithSegments(Constants.Hubs.UPDATE_HUB) || path.StartsWithSegments("/api")) + { + context.Response.StatusCode = StatusCodes.Status401Unauthorized; + return Task.CompletedTask; + } + + context.Response.Redirect(context.RedirectUri); + return Task.CompletedTask; + }; + options.Events.OnRedirectToAccessDenied = context => + { + var path = context.Request.Path; + if (path.StartsWithSegments(Constants.Hubs.UPDATE_HUB) || path.StartsWithSegments("/api")) + { + context.Response.StatusCode = StatusCodes.Status403Forbidden; + return Task.CompletedTask; + } + + context.Response.Redirect(context.RedirectUri); + return Task.CompletedTask; + }; }); builder.Services.Configure(options => From 3eecea06e66f2864095eb0a4559ddcf8fff3d97b Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Tue, 18 Nov 2025 19:46:06 +0100 Subject: [PATCH 09/18] test --- Ticky.Web/Components/Pages/BoardView.razor | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index 10b697c..2198229 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -208,11 +208,18 @@ { foreach (var cookie in httpContext.Request.Cookies) { - options.Cookies.Add(new System.Net.Cookie + var toAdd = new System.Net.Cookie { Name = cookie.Key, - Value = cookie.Value - }); + Value = cookie.Value, + Domain = string.IsNullOrWhiteSpace(hubUri.Host) ? null : hubUri.Host + }; + + // Cookie.Domain must not be an empty string; only set if available + if (toAdd.Domain is null) + toAdd.Domain = null; + + options.Cookies.Add(toAdd); } } }) From 239e6fb437a22ca697745f28b6d6d87ed3a25ef3 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:00:52 +0100 Subject: [PATCH 10/18] test --- Ticky.Web/Components/Pages/BoardView.razor | 56 ++++++++++------------ 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index 2198229..d3fed86 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -180,46 +180,42 @@ var httpContext = _httpContextAccessor.HttpContext; - Uri hubUri; - try - { - var runningInDocker = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists("/.dockerenv"); - if (runningInDocker) - { - hubUri = new Uri(new Uri("http://localhost:8080"), Constants.Hubs.UPDATE_HUB); - _logger.LogInformation("Detected Docker container. Connecting to hub at {HubUrl}", hubUri); - } - else - { - hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); - _logger.LogInformation("Connecting to hub at {HubUrl}", hubUri); - } - } - catch (Exception ex) - { - _logger.LogWarning(ex, "Failed to determine runtime environment for hub URL; falling back to NavigationManager."); - hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); - } + // Uri hubUri; + // try + // { + // var runningInDocker = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists("/.dockerenv"); + // if (runningInDocker) + // { + // hubUri = new Uri(new Uri("http:localhost:8080"), Constants.Hubs.UPDATE_HUB); + // _logger.LogInformation("Detected Docker container. Connecting to hub at {HubUrl}", hubUri); + // } + // else + // { + // hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); + // _logger.LogInformation("Connecting to hub at {HubUrl}", hubUri); + // } + // } + // catch (Exception ex) + // { + // _logger.LogWarning(ex, "Failed to determine runtime environment for hub URL; falling back to NavigationManager."); + // hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); + // } + + var uri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); _hubConnection = new HubConnectionBuilder() - .WithUrl(hubUri, options => + .WithUrl(uri, options => { if (httpContext?.Request.Cookies is not null) { foreach (var cookie in httpContext.Request.Cookies) { - var toAdd = new System.Net.Cookie + options.Cookies.Add(new System.Net.Cookie { Name = cookie.Key, Value = cookie.Value, - Domain = string.IsNullOrWhiteSpace(hubUri.Host) ? null : hubUri.Host - }; - - // Cookie.Domain must not be an empty string; only set if available - if (toAdd.Domain is null) - toAdd.Domain = null; - - options.Cookies.Add(toAdd); + Domain = uri.Host + }); } } }) From 5e853597dfebb6f0567f9a27802d7f721ec197e8 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:08:23 +0100 Subject: [PATCH 11/18] Revert "test" This reverts commit 239e6fb437a22ca697745f28b6d6d87ed3a25ef3. --- Ticky.Web/Components/Pages/BoardView.razor | 56 ++++++++++++---------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index d3fed86..2198229 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -180,42 +180,46 @@ var httpContext = _httpContextAccessor.HttpContext; - // Uri hubUri; - // try - // { - // var runningInDocker = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists("/.dockerenv"); - // if (runningInDocker) - // { - // hubUri = new Uri(new Uri("http:localhost:8080"), Constants.Hubs.UPDATE_HUB); - // _logger.LogInformation("Detected Docker container. Connecting to hub at {HubUrl}", hubUri); - // } - // else - // { - // hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); - // _logger.LogInformation("Connecting to hub at {HubUrl}", hubUri); - // } - // } - // catch (Exception ex) - // { - // _logger.LogWarning(ex, "Failed to determine runtime environment for hub URL; falling back to NavigationManager."); - // hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); - // } - - var uri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); + Uri hubUri; + try + { + var runningInDocker = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists("/.dockerenv"); + if (runningInDocker) + { + hubUri = new Uri(new Uri("http://localhost:8080"), Constants.Hubs.UPDATE_HUB); + _logger.LogInformation("Detected Docker container. Connecting to hub at {HubUrl}", hubUri); + } + else + { + hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); + _logger.LogInformation("Connecting to hub at {HubUrl}", hubUri); + } + } + catch (Exception ex) + { + _logger.LogWarning(ex, "Failed to determine runtime environment for hub URL; falling back to NavigationManager."); + hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); + } _hubConnection = new HubConnectionBuilder() - .WithUrl(uri, options => + .WithUrl(hubUri, options => { if (httpContext?.Request.Cookies is not null) { foreach (var cookie in httpContext.Request.Cookies) { - options.Cookies.Add(new System.Net.Cookie + var toAdd = new System.Net.Cookie { Name = cookie.Key, Value = cookie.Value, - Domain = uri.Host - }); + Domain = string.IsNullOrWhiteSpace(hubUri.Host) ? null : hubUri.Host + }; + + // Cookie.Domain must not be an empty string; only set if available + if (toAdd.Domain is null) + toAdd.Domain = null; + + options.Cookies.Add(toAdd); } } }) From 42edddb3786ddfa18ec175e8e868a338d1939433 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:09:03 +0100 Subject: [PATCH 12/18] test --- Ticky.Web/Program.cs | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Ticky.Web/Program.cs b/Ticky.Web/Program.cs index 954ac61..533714f 100644 --- a/Ticky.Web/Program.cs +++ b/Ticky.Web/Program.cs @@ -60,31 +60,31 @@ options.Cookie.SameSite = SameSiteMode.Lax; options.Cookie.HttpOnly = true; options.Cookie.IsEssential = true; - options.Events ??= new Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents(); - options.Events.OnRedirectToLogin = context => - { - var path = context.Request.Path; - if (path.StartsWithSegments(Constants.Hubs.UPDATE_HUB) || path.StartsWithSegments("/api")) - { - context.Response.StatusCode = StatusCodes.Status401Unauthorized; - return Task.CompletedTask; - } - - context.Response.Redirect(context.RedirectUri); - return Task.CompletedTask; - }; - options.Events.OnRedirectToAccessDenied = context => - { - var path = context.Request.Path; - if (path.StartsWithSegments(Constants.Hubs.UPDATE_HUB) || path.StartsWithSegments("/api")) - { - context.Response.StatusCode = StatusCodes.Status403Forbidden; - return Task.CompletedTask; - } - - context.Response.Redirect(context.RedirectUri); - return Task.CompletedTask; - }; + //options.Events ??= new Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents(); + //options.Events.OnRedirectToLogin = context => + //{ + // var path = context.Request.Path; + // if (path.StartsWithSegments(Constants.Hubs.UPDATE_HUB) || path.StartsWithSegments("/api")) + // { + // context.Response.StatusCode = StatusCodes.Status401Unauthorized; + // return Task.CompletedTask; + // } + + // context.Response.Redirect(context.RedirectUri); + // return Task.CompletedTask; + //}; + //options.Events.OnRedirectToAccessDenied = context => + //{ + // var path = context.Request.Path; + // if (path.StartsWithSegments(Constants.Hubs.UPDATE_HUB) || path.StartsWithSegments("/api")) + // { + // context.Response.StatusCode = StatusCodes.Status403Forbidden; + // return Task.CompletedTask; + // } + + // context.Response.Redirect(context.RedirectUri); + // return Task.CompletedTask; + //}; }); builder.Services.Configure(options => From 261c566cfa035d20504a167e3d189e81a7544d57 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:19:01 +0100 Subject: [PATCH 13/18] maybe? --- Ticky.Web/Components/Pages/BoardView.razor | 36 +++------------------- Ticky.Web/Program.cs | 25 --------------- 2 files changed, 5 insertions(+), 56 deletions(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index 2198229..ceb7ca8 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -179,47 +179,21 @@ return; var httpContext = _httpContextAccessor.HttpContext; - - Uri hubUri; - try - { - var runningInDocker = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && File.Exists("/.dockerenv"); - if (runningInDocker) - { - hubUri = new Uri(new Uri("http://localhost:8080"), Constants.Hubs.UPDATE_HUB); - _logger.LogInformation("Detected Docker container. Connecting to hub at {HubUrl}", hubUri); - } - else - { - hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); - _logger.LogInformation("Connecting to hub at {HubUrl}", hubUri); - } - } - catch (Exception ex) - { - _logger.LogWarning(ex, "Failed to determine runtime environment for hub URL; falling back to NavigationManager."); - hubUri = _navigationManager.ToAbsoluteUri(Constants.Hubs.UPDATE_HUB); - } + var uri = new Uri(Constants.BASE_URL + Constants.Hubs.UPDATE_HUB); _hubConnection = new HubConnectionBuilder() - .WithUrl(hubUri, options => + .WithUrl(uri, options => { if (httpContext?.Request.Cookies is not null) { foreach (var cookie in httpContext.Request.Cookies) { - var toAdd = new System.Net.Cookie + options.Cookies.Add(new System.Net.Cookie { Name = cookie.Key, Value = cookie.Value, - Domain = string.IsNullOrWhiteSpace(hubUri.Host) ? null : hubUri.Host - }; - - // Cookie.Domain must not be an empty string; only set if available - if (toAdd.Domain is null) - toAdd.Domain = null; - - options.Cookies.Add(toAdd); + Domain = uri.Host + }); } } }) diff --git a/Ticky.Web/Program.cs b/Ticky.Web/Program.cs index 533714f..98befe7 100644 --- a/Ticky.Web/Program.cs +++ b/Ticky.Web/Program.cs @@ -60,31 +60,6 @@ options.Cookie.SameSite = SameSiteMode.Lax; options.Cookie.HttpOnly = true; options.Cookie.IsEssential = true; - //options.Events ??= new Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents(); - //options.Events.OnRedirectToLogin = context => - //{ - // var path = context.Request.Path; - // if (path.StartsWithSegments(Constants.Hubs.UPDATE_HUB) || path.StartsWithSegments("/api")) - // { - // context.Response.StatusCode = StatusCodes.Status401Unauthorized; - // return Task.CompletedTask; - // } - - // context.Response.Redirect(context.RedirectUri); - // return Task.CompletedTask; - //}; - //options.Events.OnRedirectToAccessDenied = context => - //{ - // var path = context.Request.Path; - // if (path.StartsWithSegments(Constants.Hubs.UPDATE_HUB) || path.StartsWithSegments("/api")) - // { - // context.Response.StatusCode = StatusCodes.Status403Forbidden; - // return Task.CompletedTask; - // } - - // context.Response.Redirect(context.RedirectUri); - // return Task.CompletedTask; - //}; }); builder.Services.Configure(options => From a71aa9db93f3bf3a26363440b67c3dfb6de46b94 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:37:13 +0100 Subject: [PATCH 14/18] test --- Ticky.Web/Components/Pages/BoardView.razor | 2 +- Ticky.Web/Properties/launchSettings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index ceb7ca8..dea7e2d 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -179,7 +179,7 @@ return; var httpContext = _httpContextAccessor.HttpContext; - var uri = new Uri(Constants.BASE_URL + Constants.Hubs.UPDATE_HUB); + var uri = new Uri("https://localhost:8080" + Constants.Hubs.UPDATE_HUB); _hubConnection = new HubConnectionBuilder() .WithUrl(uri, options => diff --git a/Ticky.Web/Properties/launchSettings.json b/Ticky.Web/Properties/launchSettings.json index fe6d722..76c1661 100644 --- a/Ticky.Web/Properties/launchSettings.json +++ b/Ticky.Web/Properties/launchSettings.json @@ -14,7 +14,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": false, - "applicationUrl": "https://localhost:7225", + "applicationUrl": "https://localhost:8080", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } From cca4746f0a08eee1717db85e12829891c6f29957 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Wed, 19 Nov 2025 17:42:22 +0100 Subject: [PATCH 15/18] test --- Ticky.Web/Components/Pages/BoardView.razor | 7 ++++++- Ticky.Web/Properties/launchSettings.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index dea7e2d..65df03f 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -179,7 +179,12 @@ return; var httpContext = _httpContextAccessor.HttpContext; - var uri = new Uri("https://localhost:8080" + Constants.Hubs.UPDATE_HUB); + var uri = new Uri("http://localhost:8080" + Constants.Hubs.UPDATE_HUB); + +#if DEBUG + uri = new Uri("https://localhost:7225" + Constants.Hubs.UPDATE_HUB); +#endif + _hubConnection = new HubConnectionBuilder() .WithUrl(uri, options => diff --git a/Ticky.Web/Properties/launchSettings.json b/Ticky.Web/Properties/launchSettings.json index 76c1661..fe6d722 100644 --- a/Ticky.Web/Properties/launchSettings.json +++ b/Ticky.Web/Properties/launchSettings.json @@ -14,7 +14,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": false, - "applicationUrl": "https://localhost:8080", + "applicationUrl": "https://localhost:7225", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } From 243c1e307af84a78a1edc03c350ec096a0afb1f7 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Wed, 19 Nov 2025 18:18:20 +0100 Subject: [PATCH 16/18] Update Ticky.Web/Components/Pages/BoardView.razor Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Ticky.Web/Components/Pages/BoardView.razor | 1 - 1 file changed, 1 deletion(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index 65df03f..cb9b346 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -1,7 +1,6 @@ @page "/boards/{Id:int}/{CardId:int?}" @using System.Security.Cryptography @using System.IO -@using System.Runtime.InteropServices @inject NavigationManager _navigationManager @inject IDbContextFactory _dbContextFactory @inject ProtectedLocalStorage _protectedLocalStorage From 76de270384d30ae96da6f0bec3bad5d312f3be90 Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Wed, 19 Nov 2025 18:18:45 +0100 Subject: [PATCH 17/18] Update Ticky.Web/Program.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Ticky.Web/Program.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Ticky.Web/Program.cs b/Ticky.Web/Program.cs index 98befe7..d1cd2f8 100644 --- a/Ticky.Web/Program.cs +++ b/Ticky.Web/Program.cs @@ -156,6 +156,8 @@ mailKitOptions is null builder.Services.AddControllers(); #if !DEBUG +// NOTE: In production, the application is expected to run behind a reverse proxy (e.g., Nginx, Traefik) that terminates HTTPS. +// Binding to HTTP here is intentional and safe in that context. Do NOT expose this endpoint directly to the internet. builder.WebHost.UseUrls("http://0.0.0.0:8080"); #endif From fa17a9f7d2e391f4ed57e05af8ca4efa8ea646ab Mon Sep 17 00:00:00 2001 From: dkorecko <22599403+dkorecko@users.noreply.github.com> Date: Wed, 19 Nov 2025 18:26:34 +0100 Subject: [PATCH 18/18] only copy necessary cookie --- Ticky.Web/Components/Pages/BoardView.razor | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Ticky.Web/Components/Pages/BoardView.razor b/Ticky.Web/Components/Pages/BoardView.razor index 65df03f..fdb1816 100644 --- a/Ticky.Web/Components/Pages/BoardView.razor +++ b/Ticky.Web/Components/Pages/BoardView.razor @@ -185,21 +185,20 @@ uri = new Uri("https://localhost:7225" + Constants.Hubs.UPDATE_HUB); #endif - _hubConnection = new HubConnectionBuilder() .WithUrl(uri, options => { - if (httpContext?.Request.Cookies is not null) + var cookieName = ".AspNetCore.Identity.Application"; + var cookieValue = httpContext?.Request?.Cookies[cookieName]; + + if (!string.IsNullOrEmpty(cookieValue)) { - foreach (var cookie in httpContext.Request.Cookies) + options.Cookies.Add(new System.Net.Cookie { - options.Cookies.Add(new System.Net.Cookie - { - Name = cookie.Key, - Value = cookie.Value, - Domain = uri.Host - }); - } + Name = cookieName, + Value = cookieValue, + Domain = uri.Host + }); } }) .WithAutomaticReconnect()