@@ -0,0 +1,1204 @@
+package com.application;%0A%0A%0Aimport org.springframework.security.web.csrf.CsrfToken;%0Aimport org.springframework.web.filter.OncePerRequestFilter;%0Aimport org.springframework.web.util.WebUtils;%0A%0Aimport javax.servlet.FilterChain;%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.http.Cookie;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0Aimport java.io.IOException;%0A%0Apublic class CsrfHeaderFilter extends OncePerRequestFilter %7B%0A%09@Override%0A%09protected void doFinterlInterlan(%0A%09%09%09HttpServletRequest request,%0A%09%09%09HttpServletResponse response,%0A%09%09%09FilterChain filterChain%0A%09%09) throws ServletException, IOException %7B%0A%0A%09%09CsrfToken csrf = (CsrfToken) request.getAttribute(CsrfToken.class.getName());%0A%0A%09%09if (csrf != null) %7B%0A%09%09%09Cookie cookie = WebUtils.getCookie(request, %22XSRF-TOKEN%22);%0A%09%09%09String token = csrf.getToken();%0A%09%09%09if (cookie == null %7C%7C token != null && !token.equals(cookie.getValue())) %7B%0A%09%09%09%09cookie = new Cookie(%22XSRF-TOKEN%22, token);%0A%09%09%09%09// TODO fix setPath as it's not safe in general to point it at %22/%22 but for our app this will do now%0A%09%09%09%09cookie.setPath(%22/%22);%0A%09%09%09%09response.addCookie(cookie);%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09filterChain.doFilter(request, response);%0A%09%7D%0A%7D%0A

Add support for custom filter chain and generating the 'XSRF-TOKEN' for Angular