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 - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -