【问题标题】:Retrieve plain password from database from Spring security without decrypting从 Spring Security 从数据库中检索纯密码而不解密
【发布时间】:2020-08-21 03:45:13
【问题描述】:

我有一个要求,我需要从我下载的项目的应用程序中存储纯文本密码

来自 git hub https://github.com/bezkoder/spring-boot-spring-security-jwt-authentication 。它正在获取

作为纯文本存储在数据库中,这是我想要的,根据我删除编码的调整(我的

要求)。当我使用用户名和密码登录时出现问题。我无法找到在哪里

密码正在被解密和检查。登录失败并显示消息登录失败:

错误:未经授权。

在我看到的日志中:

未经授权的错误:凭据错误

o.s.s.c.bcrypt.BCryptPasswordEncoder : 编码密码看起来不像 BCrypt

我知道它在哪里抛出异常

Authentication authentication = authenticationManager.authenticate(
                new UsernamePasswordAuthenticationToken(loginRequest.getUsername(), loginRequest.getPassword()));

如何使用上述代码从数据库中读取纯文本密码。

【问题讨论】:

    标签: spring-boot spring-security


    【解决方案1】:

    它在第 50 到 52 行的 WebSecurityConfig 类中:

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
    

    如果你真的需要纯文本密码,那么你可以使用

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new NoOpPasswordEncoder();
    }
    

    但这将是非常不保存的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多