From b060e71bad29e1577a17fe7674ce5f8269f2bf35 Mon Sep 17 00:00:00 2001 From: Arek Tomczuk Date: Mon, 9 Feb 2026 13:52:50 +0100 Subject: [PATCH] Fixing Cookie path --- .../Configuration/ServiceCollectionExtensions.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) mode change 100644 => 100755 src/SilkierQuartz/Configuration/ServiceCollectionExtensions.cs diff --git a/src/SilkierQuartz/Configuration/ServiceCollectionExtensions.cs b/src/SilkierQuartz/Configuration/ServiceCollectionExtensions.cs old mode 100644 new mode 100755 index 929adf7..29eb9d5 --- a/src/SilkierQuartz/Configuration/ServiceCollectionExtensions.cs +++ b/src/SilkierQuartz/Configuration/ServiceCollectionExtensions.cs @@ -32,14 +32,16 @@ public static IServiceCollection AddSilkierQuartz( services.AddSingleton(authenticationOptions); if (authenticationOptions.AccessRequirement != SilkierQuartzAuthenticationOptions.SimpleAccessRequirement.AllowAnonymous) { + var normalizedVirtualPath = $"{options.VirtualPathRoot}{(options.VirtualPathRoot.EndsWith('/') ? "" : "/")}"; + var cookiePath = $"{options.BasePath}{(options.BasePath.EndsWith('/') ? "" : "/")}{normalizedVirtualPath.Trim('/')}"; services .AddAuthentication(authenticationOptions.AuthScheme) .AddCookie(authenticationOptions.AuthScheme, cfg => { cfg.Cookie.Name = authenticationOptions.CookieName; - cfg.Cookie.Path = options.VirtualPathRoot; - cfg.LoginPath = $"{options.VirtualPathRoot}{(options.VirtualPathRoot.EndsWith('/') ? "" : "/")}Authenticate/Login"; - cfg.AccessDeniedPath = $"{options.VirtualPathRoot}{(options.VirtualPathRoot.EndsWith('/') ? "" : "/")}Authenticate/Login"; + cfg.Cookie.Path = cookiePath; + cfg.LoginPath = $"{normalizedVirtualPath}Authenticate/Login"; + cfg.AccessDeniedPath = $"{normalizedVirtualPath}Authenticate/Login"; cfg.ExpireTimeSpan = TimeSpan.FromDays(7); cfg.SlidingExpiration = true; });