-
Notifications
You must be signed in to change notification settings - Fork 91
Handling http OPTIONS calls #1
Description
Hello,
When dealing with Cross-site requests, a first OPTIONS request is sent to the server before the real request.
Namely, when trying to authenticate through a POST to /api/login, first an OPTIONS request is sent, gets intercepted by the StatelessAuthenticationFilter, which then crashes because the request body is empty (no parameters are passed).
I've tried adding an exception to the config:
// allow anonymous POSTs to login
.antMatchers(HttpMethod.POST, "/api/login")
.permitAll()
// allow anonymous OPTIONs
.antMatchers(HttpMethod.OPTIONS, "/**")
.permitAll()
// allow anonymous GETs to API
but it doesn't change anything - the filter is still called (I've also tried defining the exception before the POST to /api/login)
Doing a GET directly to /api/login results in the same thing (even when changing the order of the configuration), ie the following test causes a jackson exception in StatelessLoginFilter:
@Test
public void testUserApi_Get_Login() {
final String result = doAnonymousExchange(HttpMethod.GET, "/api/login");
}
Do you know how I should proceed here?
Thanks!
Sébastien