【发布时间】: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