So I have this legacy app running with spring MVC and JSP, Reading from mongo DB
, I am thinking of replacing it with a modern app using Spring boot and angular JS
I am not looking for a framework, My question is more conceptual regarding authentication, and how it works between angular and Spring boot.
I don't want to use a third party for authentication,I would like to continue using my internal DB user and password.
I also have a rest API that clients need to register first and then send a token on every request bypassing angular and authentication.
So in the past ( ancient j2ee ) I had Servlet filter, this filter war running on any request, it checked if the session is authenticated , if not - it would forward to the authentication page, then store the result in the session.
something along the lines of this:
@WebFilter("/*")
public class LoginFilter implements Filter {
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws ServletException, IOException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
HttpSession session = request.getSession(false);
String loginURI = request.getContextPath() + "/login";
boolean loggedIn = session != null && session.getAttribute("user") != null;
boolean loginRequest = request.getRequestURI().equals(loginURI);
if (loggedIn || loginRequest) {
chain.doFilter(request, response);
} else {
response.sendRedirect(loginURI);
}
}
// ...
}
How to do the same authentication mechanism with angular JS?
what is the equivalent to filters in servlets?
since Angular is client side rendering, how to secure it?
Thank you for any input!