Spring Security - retrieve user IP, browser info and requested page

后端 未结 2 1483
被撕碎了的回忆
被撕碎了的回忆 2021-01-30 22:58

We use RequestHeaderAuthenticationFilter as to implement pre-authentication strategy and PreAuthenticatedAuthenticationProvider as the authentication p

2条回答
  •  执念已碎
    2021-01-30 23:32

    This might be a good approach:

    1) Create a class that extends SavedRequestAwareAuthenticationSuccessHandler

    public class MyCustomSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
    
        @Override
        public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
                Authentication authentication) throws ServletException, IOException {
    

    2) Assign the "success handler" to your security filter:

    
            
            
                   
        
    
    
             
             
        
    

提交回复
热议问题