I have a one-page application - more or less based on the SPA MVC5 template - using authentication tokens .
The site also has some regular MVC pages that need to be protected, but using cookie authentication .
In Startup.Auth, I can enable both types of authorization:
app.UseCookieAuthentication(new CookieAuthenticationOptions()); app.UseOAuthBearerTokens(OAuthOptions);
However, this seems like a side effect in that whenever an AJAX request is sent from the SPA, it sends the carrier token to the header and cookie.
While the behavior that I really want is that only the carrier token is used for WebAPI calls and only the cookie for MVC calls.
I also like MVC calls to redirect to the login page if they are not authorized (set as CookieAuthenticationOption), but obviously I do not want this to happen when the API is called.
Is there any way to authenticate mixed mode in one application? Perhaps through a path / route filter?
Appetere Jan 6 '14 at 15:51 2014-01-06 15:51
source share