-
Notifications
You must be signed in to change notification settings - Fork 40
Disable caching when response uses antiforgery #105
Comments
@Eilon @danroth27 could you guys triage this? Response caching middleware will otherwise cache the tokens. See aspnet/ResponseCaching#69 |
@sebastienros discussed offline. No-cache is set when there is a cookie, but it's not set if the cookie already exists and the antiforgery token is used somewhere in a form. The caller that inserts the token into the form should mark the response as non-cachable. Note response caching won't cache by default, it requires a direct opt-in |
Is this bug really just saying that any component that sets cookies should disable response caching? And that antiforgery happens to set cookies? Should components such as session state and cookie auth middleware also do this? (Or do they already do this?) |
Setting cookies will disable response caching since only responses without the The proposal is to disable caching when antiforgery is used regardless of whether cookies are being set. The question is who should disable caching. Should it be done in the antiforgery middleware or in MVC where the form was added? |
Oh I see, that makes sense. cc @rynowak to help answer the question in the last paragraph of your recent comment. |
The simple answer to your question is that there isn't an antiforgery middleware. This should be done inside the |
That may not be practical. We have to look at where it's being consumed and how it may conflict with the user setting cache headers. |
So what are we doing for 1.1? |
@kichalla can you investigate for 1.1.0? Please work with @rynowak, @Tratcher, @JunTaoLuo to figure this out. |
@JunTaoLuo Can you verify this (response caching + anti forgery). |
Tested with @sebastienros and it's been fixed. |
The commit only sets |
When setting the cookie token and headers on a response that uses antiforgery, caching should be disabled to prevent the content from being cached.
Adding the cache control headers
Cache-Control: no-cache, no-store
should be sufficient.cc @sebastienros @Tratcher
The text was updated successfully, but these errors were encountered: