[英]Where to store the JWT for authentication when Laravel is used as client?
[英]SSO Client Authentication in Laravel by using JWT
我正在嘗試基於JWT令牌在Laravel上創建身份驗證系統。 在項目中,如果用戶成功登錄,我將向API發送登錄請求並獲取Web令牌。 我正在對請求使用Guzzle軟件包。
我搜索了很多有關它的文章,但沒有一篇是有意義的。
我的控制器:
public function sigin()
{
$client = new Client();
$url = "https://localhost:8080/users/login";
$user->email = Input::get("email");
$user->password = Input::get("password");
$json_data = json_encode($user);
try{
$response = $client->request('POST',$url,[
GuzzleHttp\RequestOptions::JSON => $json_data
]);
// geting the Token in the response object. What should I do after get it
}
catch(ServerException $exception)
{
$responseBody = $exception->getResponse()->getBody(true);
}
}
使用JWT,您可以使用此令牌從數據庫中檢索用戶。 因此,將此令牌放入用戶的會話中,並在他每次進行“登錄”相關的操作時,都將其令牌發送到您的API,以檢查是否是他。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.