ApiSign.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Http\Middleware;
  3. use Closure;
  4. use App\Facades\ApiSignFacade;
  5. use App\Repositories\Eloquent\BaseRepository;
  6. class ApiSign
  7. {
  8. /**
  9. * Handle an incoming request.
  10. *
  11. * @param \Illuminate\Http\Request $request
  12. * @param \Closure $next
  13. * @return mixed
  14. */
  15. public function handle($request, Closure $next)
  16. {
  17. // $typeName = 'api认证中间件 ';
  18. // $startTime = microtime(TRUE);
  19. //
  20. // ApiSignFacade::setLog($typeName.'收到请求', $startTime, ['method'=>$request->method(), 'url'=>$request->url(), 'parameter'=>$request->all()]);
  21. //
  22. // //api请求验证
  23. // if (config('console.checkApiAuth')) {
  24. // ApiSignFacade::setLog($typeName.'开始', $startTime, ['sign'=>$request->header('sign'), 'random'=>$request->header('random'), 'timestamp'=>$request->header('timestamp')]);
  25. //
  26. // $auth = ApiSignFacade::auth($request->header('sign'), $request->header('random'), $request->header('timestamp'));
  27. //
  28. // if ($auth->getData()->code != BaseRepository::SUCCESS_CODE) {
  29. // $auth['ip'] = $request->ip();
  30. // ApiSignFacade::setLog($typeName.'失败', $startTime, [$auth]);
  31. // return response()->json($auth);
  32. // }
  33. // }
  34. //
  35. // ApiSignFacade::setLog($typeName.'通过', $startTime, ['sign'=>$request->header('sign'), 'random'=>$request->header('random'), 'timestamp'=>$request->header('timestamp')]);
  36. return $next($request);
  37. }
  38. }