Skip to content

Commit 02c72a2

Browse files
authored
Merge pull request #177 from AT-WH/master
Fixing Cookie path
2 parents bb050d3 + b060e71 commit 02c72a2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/SilkierQuartz/Configuration/ServiceCollectionExtensions.cs

100644100755
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ public static IServiceCollection AddSilkierQuartz(
3232
services.AddSingleton(authenticationOptions);
3333
if (authenticationOptions.AccessRequirement != SilkierQuartzAuthenticationOptions.SimpleAccessRequirement.AllowAnonymous)
3434
{
35+
var normalizedVirtualPath = $"{options.VirtualPathRoot}{(options.VirtualPathRoot.EndsWith('/') ? "" : "/")}";
36+
var cookiePath = $"{options.BasePath}{(options.BasePath.EndsWith('/') ? "" : "/")}{normalizedVirtualPath.Trim('/')}";
3537
services
3638
.AddAuthentication(authenticationOptions.AuthScheme)
3739
.AddCookie(authenticationOptions.AuthScheme, cfg =>
3840
{
3941
cfg.Cookie.Name = authenticationOptions.CookieName;
40-
cfg.Cookie.Path = options.VirtualPathRoot;
41-
cfg.LoginPath = $"{options.VirtualPathRoot}{(options.VirtualPathRoot.EndsWith('/') ? "" : "/")}Authenticate/Login";
42-
cfg.AccessDeniedPath = $"{options.VirtualPathRoot}{(options.VirtualPathRoot.EndsWith('/') ? "" : "/")}Authenticate/Login";
42+
cfg.Cookie.Path = cookiePath;
43+
cfg.LoginPath = $"{normalizedVirtualPath}Authenticate/Login";
44+
cfg.AccessDeniedPath = $"{normalizedVirtualPath}Authenticate/Login";
4345
cfg.ExpireTimeSpan = TimeSpan.FromDays(7);
4446
cfg.SlidingExpiration = true;
4547
});

0 commit comments

Comments
 (0)