使用Linux用户凭据进行Laravel身份验证

时间:2017-02-16 20:02:21

标签: linux laravel authentication

正如标题所说,是否有可能利用Linux用户凭证,尤其是Ubuntu for Laravel Auth?

1 个答案:

答案 0 :(得分:0)

如果我的评论是正确的,假设您要通过Laravel验证的凭据在其运行的Unbuntu服务器上,为什么不在登录控制器上重载身份验证?

<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\Auth;

class LoginController extends Controller
{
    /**
     * Handle an authentication attempt.
     *
     * @return Response
     */
    public function authenticate()
    {
        //Normal Authentication 
        if (Auth::attempt(['email' => $email, 'password' => $password])) {
            // Authentication passed...
            return redirect()->intended('dashboard');
        }

        //Now check Unbuntu credentials
        //Read /etc/passwd to find the user
        //Read /etc/shadow to validate the SHA encrypted password
        //If successful, maybe use something like Auth::loginUsingId(1)
        //Where 1 is the predefined ID of any user loggin in from Ubuntu
    }
}