Lumen Auth、Guard、User 身份驗證詳解(一)- Authentication 文件忙什麼

Wake Liu
Wake Liu
Aug 4, 2019 · 6 min read
Lumen Auth、Guard、User 身份驗證詳解 文章目錄:(一)Authentication 文件忙什麼
(二)你的架構不是你的架構
(三)全部的流程都解開了!(上)

Authentication Service Provider

$this->app['auth']->viaRequest ('api', function ($request) {  // Return User or null...});

Authentication 文件 Q&A

👉 viaRequest 函式從哪來的?是指要檢查連線請求嗎?

👉 viaRequest ('api', …) 當中的 api 是…?

👉 viaRequest (…, callback) 後面的 callback 是…?

👉 app['auth'] 又是哪來的?

👉 所以 $this->app['auth']->viaRequest ('api', callback) 這整段的意義是?

👉 真正執行的身份驗證的程式段到底在哪?

if ($this->auth->guard ($guard)->guest ()) {  return response ('Unauthorized.', 401);}
$this->app['auth']->viaRequest ('api', function ($request) {  // Return User or null...});

結語


興趣使然的程式猿

紀錄各種因愛而行的人生道路

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store