2017-02-16 145 views
1

正如标题所说,是否可以使用Linux用户凭证,尤其是Ubuntu的Laravel Auth?使用Linux用户凭证的Laravel身份验证

+0

你可以更具体一点关于'Linux用户凭证'的含义吗?你的意思是SSH凭据?或者只是正常的Linux登录?或者究竟是什么? –

+0

@ChadFisher我的意思是正常的用户登录凭据。 –

+0

一个例子是用户“root”,“www-data”等。 –

回答

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 
    } 
} 
+0

喜欢它。完善。 –