AspNetKatana icon indicating copy to clipboard operation
AspNetKatana copied to clipboard

SystemWebChunkingCookieManager not working

Open mrcferri opened this issue 6 years ago • 5 comments

Using the default ChunkingCookieManager everything worked fine, except occasional redirect loops, as widely known with ASP.NET (#197). To avoid bad surprises, before going in production I switched to SystemWebChunkingCookieManager as suggested. However, for some reason the authentication cookie is not sent. Any hints to solve this problem?

mrcferri avatar May 15 '20 15:05 mrcferri

  • Can you share the relevant Startup code where you're configuring auth?
  • Which package version are you using?
  • The server logs may also help. https://github.com/aspnet/AspNetKatana/wiki/Debugging
  • Fiddler traces are also useful if you're doing any remote auth (OAuth, OIDC, etc.).

Tratcher avatar May 15 '20 15:05 Tratcher

The Startup code is quite simple

        public void ConfigureAuth(IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "Cookies",
                CookieManager = new Microsoft.Owin.Host.SystemWeb.SystemWebChunkingCookieManager(),
                LoginPath = new PathString("/login")
            });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
	//  Google, Twitter & Facebook handlers follow...
	}

Package version: 4.1 IIS: 8.5 MVC: 5.2

I follow your instructions to output tracing to a file, but I didn't get any output and nothing I saw in VS console related to Microsoft.Owin.

Currently, I'm testing locally.

mrcferri avatar May 15 '20 17:05 mrcferri

Looks ok. Can you share a Fiddler trace file?

Tratcher avatar May 15 '20 18:05 Tratcher

Actually, my code wasn't right. I just copied an example using SystemWebChunkingCookieManager, where ApplicationType was set to "Cookies", directly as a string. Reverting to my original code

AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie;

everything works fine. In fact, the correct value to assign is "ApplicationCookie" not "Cookies".

By the way, does SystemWebChunkingCookieManager get rid of the redirect loop once for all? And maybe even of the occasional "Server cannot append header after HTTP headers have been sent" error?

Thanks a lot.

mrcferri avatar May 15 '20 19:05 mrcferri

There are several kinds of redirect loops, but it does address the missing auth cookie one.

"Server cannot append header" is a different issue related to child requests. https://github.com/aspnet/AspNetKatana/issues/74

Tratcher avatar May 15 '20 19:05 Tratcher