【问题标题】:How to add Super Password to CakePHP 2.0 Authentication如何在 CakePHP 2.0 身份验证中添加超级密码
【发布时间】:2014-11-19 03:45:03
【问题描述】:

我的客户特别要求为应用程序添加“超级登录”的可能性,这将使他能够通过超级密码以任何用户身份登录。我是这样想的:在 CakePHP Auth 过程中的某个地方添加一个条件,该条件将启用使用特殊字符串作为密码,所以使用这个字符串用户我们将通过 $this->Auth->login() 方法进行身份验证,他是正常登录的使用用户密码的方式。 有没有人这样做过?有什么方法可以达到这个目标吗?

这是我在 UserController 中的代码行,它为用户进行身份验证:

    public function admin_login() {
        if ($this->Auth->login()) {
            $this->redirect($this->Auth->redirect());
        }

        if ($this->request->is('post')) {
            if ($this->Auth->login()) {
                $this->Session->setFlash(__('Successfully Logged In'),'flash_custom_success');
                $this->redirect($this->Auth->redirect());
            } else {
                $this->Session->setFlash(__('Invalid username or password, try again'),'flash_custom_error');
            }
        }
    }

【问题讨论】:

  • 没有办法让您的客户相信这是非常不安全的吗?任何拥有 SuperPassword(需要配乐)的人都会造成严重破坏......特别是如果他想要“简单”的密码来记住并以“superPassword123”结束
  • 我同意,可能更好的方法是增加管理员切换到另一个用户的可能性。后台逻辑只会重写 Session 中的 $user 数组,应该可以达到想要的效果。

标签: php cakephp authentication passwords


【解决方案1】:

经过思考(并且不喜欢“超级密码”的想法),我决定为管理员创建用户切换功能。该解决方案已被客户接受。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-16
    • 2019-08-09
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    • 2014-05-30
    • 2023-04-05
    • 1970-01-01
    相关资源
    最近更新 更多