【问题标题】:Use Ion Auth BCrypt inside Oauth2在 Oauth2 中使用 Ion Auth BCrypt
【发布时间】:2020-12-12 21:16:16
【问题描述】:

我正在使用 CodeIgniter 4 和 OAuth2 开发 API。我有一个需要使用的现有数据库,但 Web 应用程序是由 CodeIgniter 3 制作的,并且我使用 Ion Auth 进行身份验证。如何使用 Ion Auth 的验证密码功能将用户给定的密码与数据库中的等效密码进行比较?或者有没有办法可以在没有 Ion Auth 的情况下比较密码?

我需要在位于OAuth2\Storage\Pdo.php的OAuth2中更改的代码sn-p:

 protected function checkPassword($user, $password)
{
    return $user['password'] == $this->hashPassword($password);
}

// use a secure hashing algorithm when storing passwords. Override this for your application
protected function hashPassword($password)
{
    return sha1($password);
}

我不确定我该怎么做。更糟糕的情况,我将切换回 CI3 并执行另一个 API。

非常感谢任何帮助。

【问题讨论】:

    标签: php oauth-2.0 bcrypt codeigniter-4 ion-auth


    【解决方案1】:

    我用这个替换了checkPassword 函数:

    protected function checkPassword($user, $password)
    {
        //return $user['password'] == $this->hashPassword($password);
        return password_verify($password, $user['password']);
    }
    

    就是这样!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-11
      • 1970-01-01
      • 2018-05-26
      • 1970-01-01
      • 2014-02-12
      • 2011-10-12
      • 2016-07-16
      相关资源
      最近更新 更多