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:

  1. add api_token column user table
  2. wrap routes auth::api middleware
  3. get logged user auth::guard('api')->user()
  4. update app\http\middleware\authenticate handle $request->wantsjson()

Comments

Popular posts from this blog

php - Autoloader issue not returning Class -

java - How to put two numbers separated by a space into two different arrays -

python - matplotlib equivalent for Ubuntu servers with no GUI? -