Commit 9a3608bc authored by Andreas Gärtner's avatar Andreas Gärtner

Changed security config to simpler authenticationEntryPoint

initialization.
parent 03911dd9
......@@ -82,7 +82,7 @@ public class AuthenticationFilter extends AbstractAuthenticationProcessingFilter
return;
}
}
chain.doFilter(httpRequest, httpResponse);
}
}
......@@ -15,19 +15,12 @@ import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
import org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher;
import org.springframework.security.web.util.matcher.RequestMatcher;
import org.springframework.web.bind.annotation.RequestMethod;
public class AuthenticationHandler {
@Autowired
private AuthenticationTokenService tokenService;
@Bean
public RequestMatcher ajaxRequestMatcher() {
return new RequestHeaderRequestMatcher("X-Requested-With", "XMLHttpRequest");
}
@Bean
public AuthenticationSuccessHandler authSuccessHandler() {
......@@ -36,7 +29,7 @@ public class AuthenticationHandler {
public void onAuthenticationSuccess(HttpServletRequest request,
HttpServletResponse response, Authentication authentication)
throws IOException, ServletException {
SecurityContextHolder.getContext().setAuthentication(authentication);
tokenService.authenticateUser(authentication, response);
response.setStatus(HttpServletResponse.SC_OK);
......
......@@ -105,9 +105,8 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
.addFilterBefore(authFilter(),
UsernamePasswordAuthenticationFilter.class)
.exceptionHandling().defaultAuthenticationEntryPointFor(
authHandler().tokenAuthenticationEntryPoint(),
authHandler().ajaxRequestMatcher()).and()
.exceptionHandling().authenticationEntryPoint(
authHandler().tokenAuthenticationEntryPoint()).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment