123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- use App\Facades\ApiSignFacade;
- use App\Repositories\Eloquent\BaseRepository;
- class ApiSign
- {
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- // $typeName = 'api认证中间件 ';
- // $startTime = microtime(TRUE);
- //
- // ApiSignFacade::setLog($typeName.'收到请求', $startTime, ['method'=>$request->method(), 'url'=>$request->url(), 'parameter'=>$request->all()]);
- //
- // //api请求验证
- // if (config('console.checkApiAuth')) {
- // ApiSignFacade::setLog($typeName.'开始', $startTime, ['sign'=>$request->header('sign'), 'random'=>$request->header('random'), 'timestamp'=>$request->header('timestamp')]);
- //
- // $auth = ApiSignFacade::auth($request->header('sign'), $request->header('random'), $request->header('timestamp'));
- //
- // if ($auth->getData()->code != BaseRepository::SUCCESS_CODE) {
- // $auth['ip'] = $request->ip();
- // ApiSignFacade::setLog($typeName.'失败', $startTime, [$auth]);
- // return response()->json($auth);
- // }
- // }
- //
- // ApiSignFacade::setLog($typeName.'通过', $startTime, ['sign'=>$request->header('sign'), 'random'=>$request->header('random'), 'timestamp'=>$request->header('timestamp')]);
- return $next($request);
- }
- }
|