Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Stackoverflow exception when calling the Identity Server with an expired cookie. #4844

Closed
Ausm opened this issue Sep 8, 2020 · 9 comments
Closed
Assignees

Comments

@Ausm
Copy link

Ausm commented Sep 8, 2020

When we call our IdentityServer it crashes with a stack overflow.
What we've found out is that Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandlers HandleAuthenticateAsync method calls Microsoft.AspNetCore.Identity.SignInManager.SignOutAsync when the cookie provided is not valid or expired. This sign out get picked up by the identity server to create a LogoutNotificationContext to distribute this logout to all clients the user was logged in, and calls DefaultUserSession.GetClientListAsync which requires a logged on user and that fore calls AuthenticateAsync, and the loop is complete.

We are using version 4.0.4 which is the latest one currently.
Here are the packages we use:

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="IdentityServer4" Version="4.0.4" />
    <PackageReference Include="IdentityServer4.AspNetIdentity" Version="4.0.4" />
    <PackageReference Include="Microsoft.AspNetCore.Hosting.WindowsServices" Version="3.1.5" />
    <PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
    <PackageReference Include="Serilog.Sinks.ElasticSearch" Version="8.1.0" />
    <PackageReference Include="System.Data.SQLite.Core" Version="1.0.113.1" />
  </ItemGroup>

Here is the DI configuration and startup code:

public void ConfigureServices(IServiceCollection services)
{
	services.AddMvc();
	services.AddWindowsClaimsProvider();

	services.Configure<IdentityOptions>(o => o.User.AllowedUserNameCharacters += "\\");
	services.AddOptions<SqliteUserStoreOptions>()
		.Configure<IConfiguration>((o, c) => o.ConnectionString = c.GetConnectionString("UsersDb"));
	services.AddIdentity<UserRepository.User, UserRepository.Role>()
		.AddSqliteStores()
		.AddDefaultTokenProviders();

	services.AddIdentityServer()
		.AddSigningCredentials(Configuration)
		.AddClientStore<Config>()
		.AddCorsPolicyService<Config>()
		.AddResourceStore<Config>()
		.AddAspNetIdentity<UserRepository.User>();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
	if (env.IsDevelopment())
	{
		app.UseDeveloperExceptionPage();
	}

	app.UseStaticFiles();

	app.UseRouting();
	app.UseIdentityServer();
	app.UseAuthorization();

	app.UseEndpoints(endpoints =>
	{
		endpoints.MapDefaultControllerRoute();
	});
}

I've created a fix for that already: Ausm/IdentityServer4@e7c5b07
I just didn't want to create a PR unless this is discussed in an issue to respect your contributing guidelines.

Issue / Steps to reproduce the problem

Unfortunately this happens on different Machines, and I haven't found out why it happens sometimes and sometimes not.

Relevant parts of the log file

The log file just repeats

Security stamp validation failed, rejecting cookie.
Failed to validate a security stamp.

over and over again until it fails.

Whats more helpful is a stack trace after the 5th "Failed to validate a security stamp." log:

OurProject.ServiceHub.IdentityServer.Program+TestEnricher.Enrich
Serilog.Core.Enrichers.SafeAggregateEnricher.Enrich
Serilog.Core.Logger.Dispatch
Serilog.Core.Logger.Serilog.Core.ILogEventSink.Emit
Serilog.Core.Logger.Dispatch
Serilog.Core.Logger.Serilog.Core.ILogEventSink.Emit
Serilog.Core.Logger.Dispatch
Serilog.Core.Logger.Write
Serilog.Extensions.Logging.SerilogLogger.Log
Microsoft.Extensions.Logging.Logger`1.Microsoft.Extensions.Logging.ILogger.Log
Microsoft.Extensions.Logging.LoggerExtensions.Log
Microsoft.Extensions.Logging.LoggerExtensions.LogDebug
Microsoft.AspNetCore.Identity.SignInManager`1+<ValidateSecurityStampAsync>d__35.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
Microsoft.AspNetCore.Identity.SignInManager`1.ValidateSecurityStampAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator`1.VerifySecurityStamp
Microsoft.AspNetCore.Identity.SecurityStampValidator`1+<ValidateAsync>d__16.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
Microsoft.AspNetCore.Identity.SecurityStampValidator`1.ValidateAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator.ValidateAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator.ValidatePrincipalAsync
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents.ValidatePrincipal
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler+<HandleAuthenticateAsync>d__22.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleAuthenticateAsync
Microsoft.AspNetCore.Authentication.AuthenticationHandler`1+<AuthenticateAsync>d__48.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync
IdentityServer4.Services.DefaultUserSession+<AuthenticateAsync>d__14.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
IdentityServer4.Services.DefaultUserSession.AuthenticateAsync
IdentityServer4.Services.DefaultUserSession+<GetClientListAsync>d__23.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
IdentityServer4.Services.DefaultUserSession.GetClientListAsync
IdentityServer4.Services.IUserSessionExtensions+<GetLogoutNotificationContext>d__0.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
IdentityServer4.Services.IUserSessionExtensions.GetLogoutNotificationContext
IdentityServer4.Hosting.IdentityServerAuthenticationService+<SignOutAsync>d__10.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
IdentityServer4.Hosting.IdentityServerAuthenticationService.SignOutAsync
Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignOutAsync
Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignOutAsync
Microsoft.AspNetCore.Identity.SignInManager`1+<SignOutAsync>d__34.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
Microsoft.AspNetCore.Identity.SignInManager`1.SignOutAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator`1+<ValidateAsync>d__16.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
Microsoft.AspNetCore.Identity.SecurityStampValidator`1.ValidateAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator.ValidateAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator.ValidatePrincipalAsync
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents.ValidatePrincipal
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler+<HandleAuthenticateAsync>d__22.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleAuthenticateAsync
Microsoft.AspNetCore.Authentication.AuthenticationHandler`1+<AuthenticateAsync>d__48.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync
IdentityServer4.Services.DefaultUserSession+<AuthenticateAsync>d__14.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
IdentityServer4.Services.DefaultUserSession.AuthenticateAsync
IdentityServer4.Services.DefaultUserSession+<GetClientListAsync>d__23.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
IdentityServer4.Services.DefaultUserSession.GetClientListAsync
IdentityServer4.Services.IUserSessionExtensions+<GetLogoutNotificationContext>d__0.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
IdentityServer4.Services.IUserSessionExtensions.GetLogoutNotificationContext
IdentityServer4.Hosting.IdentityServerAuthenticationService+<SignOutAsync>d__10.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
IdentityServer4.Hosting.IdentityServerAuthenticationService.SignOutAsync
Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignOutAsync
Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignOutAsync
Microsoft.AspNetCore.Identity.SignInManager`1+<SignOutAsync>d__34.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
Microsoft.AspNetCore.Identity.SignInManager`1.SignOutAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator`1+<ValidateAsync>d__16.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
Microsoft.AspNetCore.Identity.SecurityStampValidator`1.ValidateAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator.ValidateAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator.ValidatePrincipalAsync
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents.ValidatePrincipal
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler+<HandleAuthenticateAsync>d__22.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleAuthenticateAsync
Microsoft.AspNetCore.Authentication.AuthenticationHandler`1+<AuthenticateAsync>d__48.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync
IdentityServer4.Services.DefaultUserSession+<AuthenticateAsync>d__14.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
IdentityServer4.Services.DefaultUserSession.AuthenticateAsync
IdentityServer4.Services.DefaultUserSession+<GetClientListAsync>d__23.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
IdentityServer4.Services.DefaultUserSession.GetClientListAsync
IdentityServer4.Services.IUserSessionExtensions+<GetLogoutNotificationContext>d__0.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
IdentityServer4.Services.IUserSessionExtensions.GetLogoutNotificationContext
IdentityServer4.Hosting.IdentityServerAuthenticationService+<SignOutAsync>d__10.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
IdentityServer4.Hosting.IdentityServerAuthenticationService.SignOutAsync
Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignOutAsync
Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignOutAsync
Microsoft.AspNetCore.Identity.SignInManager`1+<SignOutAsync>d__34.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
Microsoft.AspNetCore.Identity.SignInManager`1.SignOutAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator`1+<ValidateAsync>d__16.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
Microsoft.AspNetCore.Identity.SecurityStampValidator`1.ValidateAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator.ValidateAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator.ValidatePrincipalAsync
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents.ValidatePrincipal
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler+<HandleAuthenticateAsync>d__22.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleAuthenticateAsync
Microsoft.AspNetCore.Authentication.AuthenticationHandler`1+<AuthenticateAsync>d__48.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync
IdentityServer4.Services.DefaultUserSession+<AuthenticateAsync>d__14.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
IdentityServer4.Services.DefaultUserSession.AuthenticateAsync
IdentityServer4.Services.DefaultUserSession+<GetClientListAsync>d__23.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
IdentityServer4.Services.DefaultUserSession.GetClientListAsync
IdentityServer4.Services.IUserSessionExtensions+<GetLogoutNotificationContext>d__0.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
IdentityServer4.Services.IUserSessionExtensions.GetLogoutNotificationContext
IdentityServer4.Hosting.IdentityServerAuthenticationService+<SignOutAsync>d__10.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
IdentityServer4.Hosting.IdentityServerAuthenticationService.SignOutAsync
Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignOutAsync
Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignOutAsync
Microsoft.AspNetCore.Identity.SignInManager`1+<SignOutAsync>d__34.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
Microsoft.AspNetCore.Identity.SignInManager`1.SignOutAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator`1+<ValidateAsync>d__16.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
Microsoft.AspNetCore.Identity.SecurityStampValidator`1.ValidateAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator.ValidateAsync
Microsoft.AspNetCore.Identity.SecurityStampValidator.ValidatePrincipalAsync
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationEvents.ValidatePrincipal
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler+<HandleAuthenticateAsync>d__22.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleAuthenticateAsync
Microsoft.AspNetCore.Authentication.AuthenticationHandler`1+<AuthenticateAsync>d__48.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync
Microsoft.AspNetCore.Authentication.AuthenticationService+<AuthenticateAsync>d__13.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.Start
Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync
IdentityServer4.Hosting.IdentityServerAuthenticationService.AuthenticateAsync
Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.AuthenticateAsync
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware+<Invoke>d__6.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke
Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware.Invoke
Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+<>c__DisplayClass4_1.<UseMiddleware>b__2
IdentityServer4.Hosting.BaseUrlMiddleware+<Invoke>d__3.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start
IdentityServer4.Hosting.BaseUrlMiddleware.Invoke
Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.SetRoutingAndContinue
Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke
Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke
Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware.Invoke
Microsoft.AspNetCore.Hosting.HostingApplication.ProcessRequestAsync
Microsoft.AspNetCore.Server.HttpSys.MessagePump+ApplicationWrapper`1.ProcessRequestAsync
Microsoft.AspNetCore.Server.HttpSys.MessagePump+<ProcessRequestAsync>d__23.MoveNext
System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start
System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start
Microsoft.AspNetCore.Server.HttpSys.MessagePump.ProcessRequestAsync
System.Threading.Tasks.Task.InnerInvoke
System.Threading.Tasks.Task+<>c.<.cctor>b__274_0
System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop
System.Threading.Tasks.Task.ExecuteWithThreadLocal
System.Threading.Tasks.Task.ExecuteEntryUnsafe
System.Threading.Tasks.Task.ExecuteFromThreadPool
System.Threading.ThreadPoolWorkQueue.Dispatch
System.Threading._ThreadPoolWaitCallback.PerformWaitCallback
@Ausm Ausm added the bug report label Sep 8, 2020
@Ausm
Copy link
Author

Ausm commented Sep 8, 2020

Meanwhile I've created a fix for me.
Looks like this:

public class FixedDefaultUserSession : IdentityServer4.Services.DefaultUserSession
{
	bool _authenticateAsyncRunning = false;

	public FixedDefaultUserSession(IHttpContextAccessor httpContextAccessor, IAuthenticationHandlerProvider handlers, IdentityServerOptions options, ISystemClock clock, ILogger<IUserSession> logger)
		: base(httpContextAccessor, handlers, options, clock, logger)
	{
	}

	protected override Task AuthenticateAsync()
	{
		if (_authenticateAsyncRunning)
			return Task.CompletedTask;

		try
		{
			_authenticateAsyncRunning = true;

			return base.AuthenticateAsync();

		}
		finally
		{
			_authenticateAsyncRunning = false;
		}
	}
}

and add this to the bottom of the ConfigureServices method:

services.RemoveAll<IdentityServer4.Services.IUserSession>();
services.AddScoped<IdentityServer4.Services.IUserSession, FixedDefaultUserSession>();

@brockallen brockallen self-assigned this Sep 8, 2020
@brockallen brockallen added this to the 4.0.5 milestone Sep 8, 2020
@brockallen
Copy link
Member

PR submitted. When we release a preview for the next patch, please test. Thanks.

@Ausm
Copy link
Author

Ausm commented Sep 8, 2020

Hi @brockallen,
thanks for looking into it so fast.
But I think your PR #4852 not gona fix this issue, because the problem is not GetClientListAsync() failing. The problem is that GetClientListAsync() is calling itself in some cases and thatfore then never returns.
And it does this via this line:


Which is outside the if block, and you can't put it in, because AuthenticateAsync(); should fill the Properties property if the user is not authenticated yet.

I'd be happy to provide you with a pull request containing a test that triggers this issue, and a possible fix.

@brockallen brockallen reopened this Sep 8, 2020
@brockallen
Copy link
Member

I'll have a look again. I thought I had repro'd your issue, but perhaps it was not the same.

@Ausm
Copy link
Author

Ausm commented Sep 9, 2020

I just tried to reproduce it, but for whatever reason, couldn't...
Looks like a kind of race condition in the startup that makes HttpContext.Response.OnStarting sometimes fired earlier and sometimes later.

@brockallen
Copy link
Member

brockallen commented Sep 9, 2020

I debugged thru it again. Here's the sequence:

Auth middleware calls Authenticate => Our auth decorator passes thru => CookieHandler.HandleAuth => raises ValidatePrincipal event => ASP.NET Identity calls Reject, and then Signout => Our auth decorator sets signed out flag, and passes thru => CookieHandler.Signout

Perhaps this fix in a prior release is what fixed it for you? #4670

It used to work like this:

Auth middleware calls Authenticate => Our auth decorator passes thru => CookieHandler.HandleAuth => raises ValidatePrincipal event => ASP.NET Identity calls Reject, and then Signout => Our auth decorator calls into UserSession service => UserSession calls Authenticate => repeat above

@brockallen
Copy link
Member

Also, I still think the PR fixes a bug (perhaps a different one) :)

brockallen added a commit that referenced this issue Sep 9, 2020
…_for_expired_cookie

add defensive check to fix bug for when session is expired #4844
@Ausm
Copy link
Author

Ausm commented Sep 10, 2020

I thought I've tried it with v4.0.4 which should contain this fix already. But maybe I used the wrong version somehow.
I would say you can close the issue, and I'll add a log message to my recursion protector and if a recursion occurs I'll reopen this issue.

Anyway, thank you very much for the work you've done.

@Ausm Ausm closed this as completed Sep 10, 2020
@leastprivilege leastprivilege removed this from the 4.1.0 milestone Sep 14, 2020
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants