title: Spring intercept http request for authorization endpoint
body: <p>I need a callback before http request on <code>/oauth/authorize</code>, I tried using the standard interceptor pattern on <code>WebMvcConfigurerAdapter</code> like follows:</p>
  
  <pre><code>@Configuration
  public class MvcConfig extends WebMvcConfigurerAdapter {
  
      @Override
      public void addInterceptors(InterceptorRegistry registry) {
          registry.addInterceptor(new UserAuthorizationInterceptor())
              .addPathPatterns("/oauth/authorize");
      }
  
  // .... 
  
  private class UserAuthorizationInterceptor implements HandlerInterceptor {
  
      @Override
      public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
          System.out.println(); // breakpoint
      }
  
      @Override
      public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
          System.out.println(); // breakpoint
      }
  
      @Override
      public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
          return true; // breakpoint
      }
  </code></pre>
  
  <p>This for some reason does not trigger for any pattern that's <code>/oauth/**</code>, however if I would replace the path matcher with something like <code>.addPathPatterns("/**");</code> it would still trigger on most http request <strong>EXCEPT</strong> anything that starts with <code>oauth</code>. How can I implement this handler? </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I tried solving this with global filter approach</p>
  
  <pre><code>@Component
  @Order(1)
  public class Foo implements Filter {
  
      @Override
      public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
          chain.doFilter(request,response); // breakpoint
      }
  
  }
  </code></pre>
  
  <p>However again, this filter is called for every http request <strong>EXCEPT</strong> <code>/oauth/**</code>. It seems to me that oauth requests are simply not passed down to the filter  chain</p>