mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-27 14:22:47 +00:00
Don't cache requests with Accept: text/event-stream
by default.
The eventstream requests is typically not directly invoked by the browser. And even more unfortunately the Browser-Api doesn't allow the set additional headers as `XMLHttpRequest`..
This commit is contained in:
parent
1ae3ec3f8a
commit
bdc60a9128
@ -162,6 +162,7 @@ public final class RequestCacheConfigurer<H extends HttpSecurityBuilder<H>> exte
|
|||||||
matchers.add(notMatchingMediaType(http, MediaType.APPLICATION_JSON));
|
matchers.add(notMatchingMediaType(http, MediaType.APPLICATION_JSON));
|
||||||
matchers.add(notXRequestedWith);
|
matchers.add(notXRequestedWith);
|
||||||
matchers.add(notMatchingMediaType(http, MediaType.MULTIPART_FORM_DATA));
|
matchers.add(notMatchingMediaType(http, MediaType.MULTIPART_FORM_DATA));
|
||||||
|
matchers.add(notMatchingMediaType(http, MediaType.TEXT_EVENT_STREAM));
|
||||||
|
|
||||||
return new AndRequestMatcher(matchers);
|
return new AndRequestMatcher(matchers);
|
||||||
}
|
}
|
||||||
|
@ -183,6 +183,21 @@ public class RequestCacheConfigurerTests {
|
|||||||
|
|
||||||
// This is desirable since XHR requests are typically not invoked directly from the browser and we don't want the browser to replay them
|
// This is desirable since XHR requests are typically not invoked directly from the browser and we don't want the browser to replay them
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
public void getWhenBookmarkedRequestIsTextEventStreamThenPostAuthenticationRedirectsToRoot() throws Exception {
|
||||||
|
this.spring.register(RequestCacheDefaultsConfig.class, DefaultSecurityConfig.class).autowire();
|
||||||
|
|
||||||
|
MockHttpSession session = (MockHttpSession)
|
||||||
|
this.mvc.perform(get("/messages")
|
||||||
|
.header(HttpHeaders.ACCEPT, MediaType.TEXT_EVENT_STREAM))
|
||||||
|
.andExpect(redirectedUrl("http://localhost/login"))
|
||||||
|
.andReturn().getRequest().getSession();
|
||||||
|
|
||||||
|
this.mvc.perform(formLogin(session))
|
||||||
|
.andExpect(redirectedUrl("/")); // ignores text/event-stream
|
||||||
|
|
||||||
|
// This is desirable since event-stream requests are typically not invoked directly from the browser and we don't want the browser to replay them
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getWhenBookmarkedRequestIsAllMediaTypeThenPostAuthenticationRemembers() throws Exception {
|
public void getWhenBookmarkedRequestIsAllMediaTypeThenPostAuthenticationRemembers() throws Exception {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user