doufan6886 2014-10-21 17:28
浏览 63

Laravel 4 - 使用自定义代码自定义auth.basic验证凭据

At the moment, when I add a before filter to my route like this:

Route::get('/', function() {
    return View::make('front');
})->before('auth.basic');

and visit my test app (e.g. http://domain.com), I see the following in Chrome:

enter image description here

What I'd like to is; when the user enters the username and password and clicks the "Login In" button - run a custom credential validation routine to verify the entered details.

By custom validation routine, I mean to make a request to external API and check if entered credentials are valid and then return true/false to the basic auth attempt.

Is this possible? Does this involve writing a custom auth.basic driver?

  • 写回答

1条回答 默认 最新

  • dsnrixf6765 2014-10-21 17:45
    关注

    While using auth.basic authentication in laravel, it uses the HTTP basic authentication for the website, meaning that it asks and appends username and password in the HTTP header of the packets. Saying that, browsers are prepared to take care of HTTP basic authentication and does it before processing the body of the packet, meaning that you see the pop-up shown.

    use laravel's auth instead. It checks if the user is already logged in by the registered Auth::check() in session, and if not, redirects to your login url and stores the intended url in session to redirect after authentication is passed. See Laravel Documentation.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?