title: Is it a good practice to authenticate user from Database in Filter?
body: <p>I am creating a Rest API (Spring Boot project) for Android App. What should be the ideal way of authenticating User from the database?<br/><br/>
  <strong>1. Querying database in Controller Class<br/>
  2. Querying database in Filter Class<br/>
  3. Using Spring Security</strong><br/></p>
  
  <pre><code>    public class TokenValidationFilter implements Filter {
  
          Connection connection = null; 
  
          @Override
          public void doFilter(ServletRequest request, 
              ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
              final String accessToken = req.getHeader("accessToken");
              final String userId = req.getHeader("userId");
  
              // Do Sql Query to Authenticate User
          }
  
          @Override
          public void init(FilterConfig filterConfig) throws ServletException {}
   }
  </code></pre>