/** * 获取绑定SSO服务应用对应的配置 */ public function configs() { $result = false; $mServiceBind = new ServiceBinding(); $appids = $mServiceBind->getAllAppID($this->serviceID); if ($appids) { // TODO: 获取指定个应用的配置数据 $result = SsoSettingInfo::findByAppIds($appids); /* $result = [ [ 'id' => 1, 'app_id' => '10001', 'domain_white_list' => [ 'www.iheima.com', 'app.iheima.net', 'www.iheima.net', ], 'ip_white_list' => [ '182.92.76.1', ], 'profile_api' => [ 'auth' => [ 'app_id' => 'ihm2c677f02a36095e6a2c94495d0597', 'app_secret' => 'ihm10001', ], 'api' => [ 'domain' => 'app.iheima.net', 'mobile' => 'app=member&controller=userdatacenter&action=mobile_datacenter', 'email' => 'app=member&controller=userdatacenter&action=email', 'password' => 'app=member&controller=userdatacenter&action=password', 'profile' => 'app=member&controller=userdatacenter&action=profile', 'access_token' => 'app=ihminterface&controller=igrant&action=getAccessToken', ] ] ], ]; */ } return $result; }
public function check($data, $isISystem = false) { $requiredItems = $this->getRequiredItems($isISystem); foreach ($requiredItems as $key => $item) { if (!isset($data[$key])) { return $item; } } if (!$isISystem) { $mAppBase = new ApplicationBase(); $appNO = $data['appNO']; $appInfo = $mAppBase->pk($appNO); if (!$appInfo) { return [2201, 'error_appno_invalid']; } $appKey = $appInfo['app_key']; $appID = trim(Yii::$app->util->decrypt($data['appID'], $appKey)); if ($appID !== $appInfo['app_id']) { return [2202, 'error_appid_invalid']; } } else { $appID = $data['appID']; } $mAppService = new ServiceBinding(); $serviceID = $this->getServiceID(); $appService = $mAppService->getAppService($appID, $serviceID); if (!$appService) { return [2401, 'error_service_not_bound']; } if (!$isISystem) { $asKey = $appService['as_key']; if (!Yii::$app->sign->checkSign($data, $asKey)) { return [1201, 'error_sign']; } } return $this->customCheck($appID, $data, $isISystem); }
/** * 根据AppId构造key * * @param string $type * ~ * EMAIL:MINUTE: * EMAIL:STATUS: * EMAIL:BUSI: * EMAIL:RECUSER: * ~ * @param string $date * ~~ * date('Ymd') * ~~ * @param string | int $status 0 1 * * @return array $keys[appId]=$type . ':' . $appId . ':' . $date; */ private function _structKeys($type, $date, $status = '') { $keys = []; try { $servicBinding = new ServiceBinding(); // 获取所有的AppID $appIds = $servicBinding->getAllAppId(self::SERVICEID); if (empty($appIds)) { $this->stdout("不存在绑定邮件业务的第三方应用系统!!!\r\n", Console::FG_RED); $this->_fileLogger->writeOne("不存在绑定邮件业务的第三方应用系统!!!", Logger::LEVEL_INFO, 'console\\controllers\\EmailController::_structKeys'); // 目标数据不存在 exit(6); } foreach ($appIds as $appId) { if (is_numeric($status)) { $keys[$appId] = $type . $appId . ':' . $status . ':' . $date; } else { $keys[$appId] = $type . $appId . ':' . $date; } } return $keys; } catch (\yii\db\Exception $ex) { $this->stdout("网络出现异常,请稍后重试~~\r\n", Console::FG_RED); $this->_fileLogger->writeOne($ex->getMessage(), Logger::LEVEL_ERROR, 'console\\controllers\\EmailController::getAllAppId'); exit(1); } }
/** * 应用服务解除绑定 */ public function actionUnbindingServiceSubmit() { $res = Yii::$app->request->get(); $appId = $res['appId']; $serviceId = $res['serviceId']; $id = $res['id']; $serviceBinding = new ServiceBinding(); if ($serviceBinding->updateStatus($appId, $serviceId)) { return $this->redirect(['binding-service-view', 'id' => $id]); } else { return $this->redirect(['binding-service-view', 'id' => $id]); } }