Code Monkey home page Code Monkey logo

owin-cookie-saver's Introduction

Kentor.OwinCookieSaver

There is a bug in Microsoft's Owin implementation for System.Web. The one that is being used when running Owin applications on IIS. Which is what probably 99% of us do, if we're using the new Owin-based authentication handling with ASP.NET MVC5.

The makes cookies set by Owin mysteriously disappear on some occasions. There is some documentation from Microsoft on workarounds, but this middleware offers another solution.

This middleware is a fix for that bug. Simple add it before any cookie handling middleware and it will preserve the authentication cookies.

app.UseKentorOwinCookieSaver();

app.UseCookieAuthentication(new CookieAuthenticationOptions());

In some cases, a pipeline stage specification might be needed. Using SignalR without other middleware containing a stage marker is such a case.

app.UseKentorOwinCookieSaver(PipelineStage.Authenticate);

Nuget package

The middleware is available as a nuget package, Kentor.OwinCookieSaver.

Limitations

Due to how the cookies are handled, this middleware is only able to save cookies that are added by middleware; such as the authentication cookie. It won't save cookies handled by normal MVC Actions. In that case, the workaround of adding a dummy session value is recommended (if the application uses session, which is the most likely reason to be affected by this bug).

Plans for a Real Fix

I've discussed contributing the functionality of this library directly to Katana to make this middleware redundant. However Microsoft do not want this behaviour added as it can affect cookie behaviour. In some cases it will loose newer flags on cookies. As ASP.NET Core is the clearly the route forward, there will be no more substantial development on this library.

owin-cookie-saver's People

Contributors

andersabel avatar andreize avatar spottedmahn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.