php - Laravel 5.3 - Custom API Guard -
i have 2 endpoint :
route::get('user', function () { $data = ...; return response()->json($data); }); route::get('user-premium', function () { $data = ...; return response()->json($data); });
in user-premium, ii need restrict aaccess token (but don't want use jwt or database)
i plan use env variable, api_token=xxx
so, how make custom guard base on env variable
my goal request /api/user-premium/?token=xxx
, xxx
value env variable
i think looking this
in short:
- add api_token column
user
table - wrap routes
auth::api
middleware - get logged user
auth::guard('api')->user()
- update
app\http\middleware\authenticate
handle$request->wantsjson()
Comments
Post a Comment