get('app_id', ''); $service = new ConfigService; $validate = new CompanyAuthRequest($request); $validate->validate(); $client_ip = CommonHelper::GetClientIp(); \Log::info('appid:'.$app_id.' ip:'.$client_ip); // if(true){ if (in_array($client_ip, $service->CompanyAuthIps($app_id))) { $params = $request->except('_url'); $timestamp = (int) $params['timestamp']; $diff = time() - $timestamp; if ($diff < SysConsts::ONE_MINUTE_SECONDS * 60) { $config = $service->findCompanyAuthConfig($params['app_id']); // 检查channel_id所属appid $channel_ids = $service->findCompanyChannelIds($config->company_id); // 获取该公司下的所有渠道ID $request_channel_id = $request->get('channel_id', ''); if ($request_channel_id && !in_array($request_channel_id, $channel_ids)) { return response()->error('CHANNEL_AUTH_INVALID'); } if (isset($params['sign']) && strcasecmp(CommonHelper::sign($params, $config->app_secret), $params['sign']) == 0) { $this->setGlobalConfig($config); return $next($request); } else { CommonHelper::myLog('test')->info(CommonHelper::sign($params, $config->app_secret)); return response()->error('COMPANY_AUTH_SIGN_ERROR'); } } else { return response()->error('COMPANY_AUTH_EXPIRED'); } } else { return response()->error('COMPANY_AUTH_IP_NOT_EXISTS', [ 'ip' => $client_ip ]); } } }