Request not reaching to the controller but still get 200 response

前端 未结 2 1026
一整个雨季
一整个雨季 2021-01-24 04:22

I was playing around spring security and trying to secure an restful application, but then ran into this rather absurd problem. All the action on my controllers are fine and the

相关标签:
2条回答
  • 2021-01-24 05:09

    You must pass on the request on to the chain and you don't in case (header != null && headerContainsprefix)

    0 讨论(0)
  • 2021-01-24 05:14

    After struggling some time I found the problem. It was indeed a stupid mistake that I made. and it was on the Authorization filter. changed

     if (null != header) {
                final var headerContainsPrefix = header.startsWith(TOKEN_PREFIX);
    
                if (!headerContainsPrefix) {
                    chain.doFilter(request, response);
                    return;
                }
                return;
            }
    

    to :

     if (null != header) {
                final var headerContainsPrefix = header.startsWith(TOKEN_PREFIX);
    
                if (!headerContainsPrefix) {
                    chain.doFilter(request, response);
                    return;
                }
            }
    

    and seems to solve the problem.

    0 讨论(0)
提交回复
热议问题