Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring security 从Spring安全身份验证日志中删除日志_Spring Security - Fatal编程技术网

Spring security 从Spring安全身份验证日志中删除日志

Spring security 从Spring安全身份验证日志中删除日志,spring-security,Spring Security,在AbstractUserDetailsAuthenticationProvider.class中,我们有一个方法AbstractUserDetailsAuthenticationProvider.authenticate,如果找不到用户名,将引发BadCredentials异常: try { user = retrieveUser(username, (UsernamePasswordAuthenticationToken) authentication); }

在AbstractUserDetailsAuthenticationProvider.class中,我们有一个方法AbstractUserDetailsAuthenticationProvider.authenticate,如果找不到用户名,将引发BadCredentials异常:

    try {
        user = retrieveUser(username, (UsernamePasswordAuthenticationToken) authentication);
    } catch (UsernameNotFoundException notFound) {
        ***logger.debug("User '" + username + "' not found");***

        if (hideUserNotFoundExceptions) {
            throw new BadCredentialsException(messages.getMessage(
                    "AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials"));
        } else {
            throw notFound;
        }
    }

如果我不想记录错误消息logger.debug(“用户“+”用户名+“”未找到”),该怎么办?因为这是一个安全漏洞(如果用户意外地在用户名中输入密码,那么它就会被记录下来)。

通常,当您在生产环境中运行应用程序时,您不应该将整个日志记录级别设置为
debug
,看看要用哪一个

但是,您可以将此类的日志记录级别配置为比
debug
更详细的级别,如
info
。这样它就不会记录
User x not found
条目

要设置单个类的日志级别(取决于实现),请参阅