【发布时间】:2013-04-06 18:02:34
【问题描述】:
这看起来很简单,但我真的想不通。我想在 Laravel 4 中使用Auth::attempt($credentials),但密码已经过哈希处理(因为它是一个 API)。当我发送未散列的密码时它可以工作,但我不明白如何告诉 Auth “不散列”给定的密码。
快速“演示”
什么有效:
Auth::attempt([Request::getUser(), Request::getPassword()]);
curl --user username:notHashedPassword localhost:8000/api/
什么不起作用:
Auth::attempt([Request::getUser(), Request::getPassword()]);
curl --user username:$2y$08$xo7HpxFyeF2UKHOYs/e localhost:8000/api/
我是否可以将任何参数传递给 Auth::attempt(),告诉它按原样使用它而不是尝试重新散列它(就像我认为的那样)?
【问题讨论】:
-
浏览代码:定义您自己的
UserProviderInterface实现,或者如果您想使用内置的db / eloquent 提供程序,请注册一个实现HasherInterface的非散列类。
标签: php authentication laravel