Changing the login service URL in spring security

后端 未结 5 2210
攒了一身酷
攒了一身酷 2021-01-01 02:12

Hi I have implemented Spring security in my spring boot web application with JWT filters. But the default authentication is happening at url http://localhost:8080/logi

5条回答
  •  暖寄归人
    2021-01-01 02:32

    In your AuthenticationFilter you can call setFilterProcessesUrl during construction, example:

    public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter {
    
       private AuthenticationManager authenticationManager;
    
       public JWTAuthenticationFilter(AuthenticationManager authenticationManager) {
          this.authenticationManager = authenticationManager;
    
          setFilterProcessesUrl("/api/v1/tokens"); // <--- like this
       }
    
       ...
    

    Hope it helps.

提交回复
热议问题