sfGuard custom algorithm_callable

主宰稳场 提交于 2019-12-11 17:36:44

问题


I am trying to make custom algorithm for password hashing. I try to do this.

In app.cfg:

sf_guard_plugin:
  algorithm_callable: [Hlp, noHash]

In apps/frontend/lib/Hlp.php:

class Hlp
{
  function noHash($password) //tried to make public or public static, but it didn't work either
  {
    return $password;
  }
}

And in my database 'algorithm' is set to 'noHash'. When I try to log in I get following error:

The algorithm callable "noHash" is not callable.

I am using php 5.2.

What am I doing wrong?

UPDATE Change in app.yml: algorithm_callable: 'Hlp::noHash'

Changed algorith in db to 'Hlp::noHash'

Marking hakre's answer as correct for providing useful tip.


回答1:


The sfGuardPlugin 1.3 expects the function to be static in case you want to call a class member.

However in your case the error message explicitly states that you're calling a global public function, otherwise the error message would have been

The algorithm callable "Hlp::noHash" is not callable.

So check the settings. Check the PHP requirements. And if in doubt, read the source.




回答2:


You should properly define your functions. Time to leave the PHP 4 era behind. Also, you need PHP >5.2.4

...
public static function noHash($password)
...

And you do mean app.yml right?



来源:https://stackoverflow.com/questions/6382579/sfguard-custom-algorithm-callable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!