Lumen Auth、Guard、User 身份驗證詳解(二)- 你的架構不是你的架構

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

設定檔之謎

啟用身份驗證時的預設項目

'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],

Guard 設定內容

'guards' => [  'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],

使用者物件提供模組

'providers' => [  'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
// ],
],

回到 Lumen

'defaults' => [
'guard' => env ('AUTH_GUARD', 'api'),
],

'guards' => [
'api' => ['driver' => 'api'],
],

'providers' => [
//
],

小結

基本身份驗證架構

Image for post
Image for post
Image for post
Image for post

結語


興趣使然的程式猿

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

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