记录401认证错误spring boot的用户名/密码

时间:2017-05-11 18:08:52

标签: java spring authentication spring-boot spring-security

我想记录给定经过身份验证的Web服务的用户名和密码。

我的struct Concept { let text: String let area: NSRect func draw() { text.draw(inRect: area) } } let conceptRect = NSRect(x: 50, y: 60, width: 80, height: 20) let concept = Concept(text: "sample text", area: conceptRect) let textField = NSTextField() textField.stringValue = concept.text textField.???? = area let textFieldRect = textField.frame assert(textFieldRect != conceptRect) assert(textFieldRect.contains(conceptRect)) 配置如下:

WebSecurityConfigurerAdapter

我想要的是获取http请求并记录用户名和密码,如example

所以我想要的是如何在春季启动时获取我的Web服务的http请求并记录凭据,无论用户和传递是否正确。

1 个答案:

答案 0 :(得分:3)

考虑在您的应用程序中添加LoggingFilter。

@Bean
public FilterRegistrationBean loggingFilterRegistration() {

    FilterRegistrationBean loggingBean = new FilterRegistrationBean();
    loggingBean.setFilter(loggingFilter());
    loggingBean.addUrlPatterns("/login");
    loggingBean.setName("loggingFilter");
    return registration;
} 

@Bean
public Filter loggingFilter() {
    return new GenericFilterBean {
       @Override
       public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
              if("POST".equalsIgnoreCase(request.getMethod())){
              // Implement Logging logic here
              }
      }
   }
}