编写LoginHandlerInterceptor
@Configuration
public class LoginHandlerInterceptor extends HandlerInterceptorAdapter {
private static final Logger logger = LoggerFactory.getLogger(LoginHandlerInterceptor.class);
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
return super.preHandle(request, response, handler);
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
logger.debug("modelAndView{}", modelAndView);
logger.debug("handler{}", handler);
logger.debug("response{}", response);
logger.debug("request{}", request);
// 获取ip
String ipAddr = RequestIpUtil.getIpAddress(request);
super.postHandle(request, response, handler, modelAndView);
}
}
@Autowired
private LoginHandlerInterceptor loginHandlerInterceptor;
@Override
public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
endpoints.tokenStore(getRedisTokenStore())
.userDetailsService(ssoUserDetailsService)
// 如果这个不写着 会报Unsupported grant type: password
.authenticationManager(authenticationManager)
.addInterceptor(loginHandlerInterceptor)
.exceptionTranslator(customWebResponseExceptionTranslator);
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。