Commit 94d443675e19eb864dfb8b4301501dd3f36183fd

Authored by xu
1 parent c8082ab0
Exists in master

app-api

1. F 调整新的rsakey
app-ht
1. 调整后台各个功能模块的顺序
2. 欢迎界面调整
common
1. F RSA 独立一下key
2. F 失败的授权接口重新授权时间调整
app-api/config/url-rules.php
@@ -5,13 +5,13 @@ return [ @@ -5,13 +5,13 @@ return [
5 5
6 6
7 'POST authDevice' => 'auth-device/index', 7 'POST authDevice' => 'auth-device/index',
8 - 'POST authDeviceT' => 'auth-device/indext', 8 + //'POST authDeviceT' => 'auth-device/indext',
9 'POST checkOtaVersion' => 'upgrade/check-version', 9 'POST checkOtaVersion' => 'upgrade/check-version',
10 'POST reportOtaUpgradeEvent' => 'upgrade/report-upgrade-event', 10 'POST reportOtaUpgradeEvent' => 'upgrade/report-upgrade-event',
11 'POST checkAppVersion' => 'upgrade/check-app-version', 11 'POST checkAppVersion' => 'upgrade/check-app-version',
12 'POST reportAppUpgradeEvent' => 'upgrade/report-app-upgrade-event', 12 'POST reportAppUpgradeEvent' => 'upgrade/report-app-upgrade-event',
13 'POST reportDeviceVersion' => 'upgrade/report-device-version', 13 'POST reportDeviceVersion' => 'upgrade/report-device-version',
14 - 'POST CryptTxt' => 'auth-device/crypt-txt', 14 + //'POST CryptTxt' => 'auth-device/crypt-txt',
15 'GET errorPage' => 'site/error-page-info', 15 'GET errorPage' => 'site/error-page-info',
16 'GET minaQuery' => 'site/mina-query', 16 'GET minaQuery' => 'site/mina-query',
17 ]; 17 ];
18 \ No newline at end of file 18 \ No newline at end of file
app-api/controllers/AuthDeviceController.php
@@ -31,6 +31,7 @@ use function time; @@ -31,6 +31,7 @@ use function time;
31 class AuthDeviceController extends BaseController 31 class AuthDeviceController extends BaseController
32 { 32 {
33 private static $SIGN_SALT = '13456'; 33 private static $SIGN_SALT = '13456';
  34 + private static $RANDOM_KEY_SALT = '12356';
34 35
35 private static function myLog($str) 36 private static function myLog($str)
36 { 37 {
@@ -38,10 +39,10 @@ class AuthDeviceController extends BaseController @@ -38,10 +39,10 @@ class AuthDeviceController extends BaseController
38 } 39 }
39 40
40 /** 41 /**
41 - * 设备授权接口 42 + * 设备授权接口,未加密的
42 * @return stdClass 43 * @return stdClass
43 */ 44 */
44 - public function actionIndex() 45 + private function indexNoEncode()
45 { 46 {
46 $getPostData = file_get_contents('php://input', 'r'); 47 $getPostData = file_get_contents('php://input', 'r');
47 self::myLog('actionIndex postData:'.$getPostData); 48 self::myLog('actionIndex postData:'.$getPostData);
@@ -50,6 +51,40 @@ class AuthDeviceController extends BaseController @@ -50,6 +51,40 @@ class AuthDeviceController extends BaseController
50 } 51 }
51 52
52 /** 53 /**
  54 + * 设备授权接口加密过的
  55 + * @return stdClass
  56 + */
  57 + public function actionIndex()
  58 + {
  59 + $e = new stdClass();
  60 + $e->content = '';
  61 +
  62 + $getPostData = file_get_contents('php://input', 'r');
  63 + self::myLog('actionIndext postData:'.$getPostData);
  64 + $getPostData = json_decode($getPostData, true);
  65 + $randomKey = $getPostData['randomKey'];
  66 + $content = $getPostData['content'];
  67 + $rsaKeys = Yii::$app->params['AUTH_DEVICE_RSA_PKCS_1'];
  68 + $rsa = new RSACrypt($rsaKeys['PRIVATE'], $rsaKeys['PUBLIC']);
  69 + $randKey = $rsa->decrypt($randomKey);
  70 + if (16 != strlen($randKey)) {
  71 + // 检查randKey,当前只是做长度判断
  72 + $randKey = null;
  73 + } else {
  74 + $randKey = substr(md5($randKey. self::$RANDOM_KEY_SALT), 8, 16);
  75 + }
  76 +
  77 + $aes = new Aes($randKey);
  78 + $contentStr = $aes->decrypt($content);
  79 + $authResult = $this->authDevice($contentStr);
  80 +
  81 + $returnStr = json_encode($authResult, JSON_UNESCAPED_UNICODE);
  82 + $e->content = $aes->encrypt($returnStr);
  83 +
  84 + return $e;
  85 + }
  86 +
  87 + /**
53 * @param $getPostData 88 * @param $getPostData
54 * @return stdClass 89 * @return stdClass
55 */ 90 */
@@ -70,7 +105,7 @@ class AuthDeviceController extends BaseController @@ -70,7 +105,7 @@ class AuthDeviceController extends BaseController
70 $manufactureNo = isset($getPostData['manufacture'])?$getPostData['manufacture']:''; 105 $manufactureNo = isset($getPostData['manufacture'])?$getPostData['manufacture']:'';
71 $deviceId = isset($getPostData['device_id'])?$getPostData['device_id']:''; 106 $deviceId = isset($getPostData['device_id'])?$getPostData['device_id']:'';
72 $projectNo = isset($getPostData['project'])?$getPostData['project']:''; 107 $projectNo = isset($getPostData['project'])?$getPostData['project']:'';
73 - $modelNo = isset($getPostData['model'])?$getPostData['model']:''; 108 + $modelNo = isset($getPostData['model'])?$getPostData['model']:'';
74 $productionNo = isset($getPostData['production'])?$getPostData['production']:''; 109 $productionNo = isset($getPostData['production'])?$getPostData['production']:'';
75 $timestamp = isset($getPostData['timestamp'])?$getPostData['timestamp']:''; 110 $timestamp = isset($getPostData['timestamp'])?$getPostData['timestamp']:'';
76 $sign = isset($getPostData['sign'])?$getPostData['sign']:''; 111 $sign = isset($getPostData['sign'])?$getPostData['sign']:'';
@@ -121,7 +156,9 @@ class AuthDeviceController extends BaseController @@ -121,7 +156,9 @@ class AuthDeviceController extends BaseController
121 $getPostData = json_decode($getPostDataTxt, true); 156 $getPostData = json_decode($getPostDataTxt, true);
122 $randomKey = $getPostData['randomKey']; 157 $randomKey = $getPostData['randomKey'];
123 $content = $getPostData['content']; 158 $content = $getPostData['content'];
124 - $rsa = new RSACrypt(); 159 + $rsaKeys = Yii::$app->params['AUTH_DEVICE_RSA_PKCS_1'];
  160 + $rsa = new RSACrypt($rsaKeys['PRIVATE'], $rsaKeys['PUBLIC']);
  161 +
125 $randKey = $rsa->decrypt($randomKey); 162 $randKey = $rsa->decrypt($randomKey);
126 $aes = new Aes($randKey); 163 $aes = new Aes($randKey);
127 $contentStr = $aes->decrypt($content); 164 $contentStr = $aes->decrypt($content);
@@ -137,34 +174,4 @@ class AuthDeviceController extends BaseController @@ -137,34 +174,4 @@ class AuthDeviceController extends BaseController
137 return $e; 174 return $e;
138 } 175 }
139 176
140 - /**  
141 - * @return stdClass  
142 - */  
143 - public function actionIndext()  
144 - {  
145 - $e = new stdClass();  
146 - $e->content = '';  
147 -  
148 - $getPostData = file_get_contents('php://input', 'r');  
149 - self::myLog('actionIndext postData:'.$getPostData);  
150 - $getPostData = json_decode($getPostData, true);  
151 - $randomKey = $getPostData['randomKey'];  
152 - $content = $getPostData['content'];  
153 - $rsa = new RSACrypt();  
154 - $randKey = $rsa->decrypt($randomKey);  
155 - if (16 != strlen($randKey)) {  
156 - // 检查randKey,当前只是做长度判断  
157 - $randKey = null;  
158 - }  
159 - $aes = new Aes($randKey);  
160 - $contentStr = $aes->decrypt($content);  
161 - $authResult = $this->authDevice($contentStr);  
162 -  
163 - $returnStr = json_encode($authResult, JSON_UNESCAPED_UNICODE);  
164 -  
165 - $e->content = $aes->encrypt($returnStr);  
166 -  
167 - return $e;  
168 - }  
169 -  
170 } 177 }
171 \ No newline at end of file 178 \ No newline at end of file
app-ht/modules/device/controllers/DeviceController.php
@@ -716,7 +716,7 @@ class DeviceController extends BaseController @@ -716,7 +716,7 @@ class DeviceController extends BaseController
716 $e->success = false; 716 $e->success = false;
717 } elseif(DeviceStatus::NO_AUTH == $deviceModel->status) { 717 } elseif(DeviceStatus::NO_AUTH == $deviceModel->status) {
718 $deviceModel->status = DeviceStatus::HAS_AUTH; 718 $deviceModel->status = DeviceStatus::HAS_AUTH;
719 - $deviceModel->auth_at = time(); 719 + //$deviceModel->auth_at = time();
720 $deviceModel->save(); 720 $deviceModel->save();
721 $e->message = '已经存在该授权设备'; 721 $e->message = '已经存在该授权设备';
722 $e->success = false; 722 $e->success = false;
@@ -756,7 +756,7 @@ class DeviceController extends BaseController @@ -756,7 +756,7 @@ class DeviceController extends BaseController
756 $newDeviceModel->device_id = $deviceId; 756 $newDeviceModel->device_id = $deviceId;
757 $newDeviceModel->status = DeviceStatus::NO_AUTH; 757 $newDeviceModel->status = DeviceStatus::NO_AUTH;
758 $newDeviceModel->apply_at = $tt ; 758 $newDeviceModel->apply_at = $tt ;
759 - $newDeviceModel->auth_at = $tt; 759 + //$newDeviceModel->auth_at = $tt;
760 $newDeviceModel->save(); 760 $newDeviceModel->save();
761 761
762 $deviceFailModel->is_delete = 1; 762 $deviceFailModel->is_delete = 1;
app-ht/modules/device/views/device/delete-index.php
@@ -21,11 +21,11 @@ $this->params['breadcrumbs'][] = $this->title; @@ -21,11 +21,11 @@ $this->params['breadcrumbs'][] = $this->title;
21 </div> 21 </div>
22 <label for="project" class="col-sm-1 control-label text-right">项目名:</label> 22 <label for="project" class="col-sm-1 control-label text-right">项目名:</label>
23 <div class="col-sm-2 form-inline"> 23 <div class="col-sm-2 form-inline">
24 - <input type="text" class="form-control" id="project" name="project" value="<?php if (!empty($gets['project'])){ echo $gets['project'];} ?>" autocomplete="off"> 24 + <input type="text" class="form-control" id="project" placeholder="项目关键字" name="project" value="<?php if (!empty($gets['project'])){ echo $gets['project'];} ?>" autocomplete="off">
25 </div> 25 </div>
26 <label for="model" class="col-sm-1 control-label text-right">型号:</label> 26 <label for="model" class="col-sm-1 control-label text-right">型号:</label>
27 <div class="col-sm-2 form-inline"> 27 <div class="col-sm-2 form-inline">
28 - <input type="text" class="form-control" id="model" name="model" value="<?php if (!empty($gets['model'])){ echo $gets['model'];} ?>" autocomplete="off"> 28 + <input type="text" class="form-control" id="model" placeholder="型号关键字" name="model" value="<?php if (!empty($gets['model'])){ echo $gets['model'];} ?>" autocomplete="off">
29 </div> 29 </div>
30 <label for="status" class="col-sm-1 control-label text-right">状态:</label> 30 <label for="status" class="col-sm-1 control-label text-right">状态:</label>
31 <div class="col-sm-2 form-inline"> 31 <div class="col-sm-2 form-inline">
@@ -42,11 +42,11 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -42,11 +42,11 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
42 <div class="form-group col-sm-12"> 42 <div class="form-group col-sm-12">
43 <label for="production" class="col-sm-1 control-label text-right">生产日期:</label> 43 <label for="production" class="col-sm-1 control-label text-right">生产日期:</label>
44 <div class="col-sm-2 form-inline"> 44 <div class="col-sm-2 form-inline">
45 - <input type="text" class="form-control" id="production" name="production" value="<?php if (!empty($gets['production'])){ echo $gets['production'];} ?>" autocomplete="off"> 45 + <input type="text" class="form-control" id="production" placeholder="生产日期关键字" name="production" value="<?php if (!empty($gets['production'])){ echo $gets['production'];} ?>" autocomplete="off">
46 </div> 46 </div>
47 <label for="manufacture" class="col-sm-1 control-label text-right">厂商:</label> 47 <label for="manufacture" class="col-sm-1 control-label text-right">厂商:</label>
48 <div class="col-sm-2 form-inline"> 48 <div class="col-sm-2 form-inline">
49 - <input type="text" class="form-control" id="manufacture" name="manufacture" value="<?php if (!empty($gets['manufacture'])){ echo $gets['manufacture'];} ?>" autocomplete="off"> 49 + <input type="text" class="form-control" id="manufacture" placeholder="厂商关键字" name="manufacture" value="<?php if (!empty($gets['manufacture'])){ echo $gets['manufacture'];} ?>" autocomplete="off">
50 </div> 50 </div>
51 <label for="mac" class="col-sm-1 control-label text-right">MAC地址:</label> 51 <label for="mac" class="col-sm-1 control-label text-right">MAC地址:</label>
52 <div class="col-sm-2 form-inline"> 52 <div class="col-sm-2 form-inline">
app-ht/modules/device/views/device/index.php
@@ -21,11 +21,11 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -21,11 +21,11 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
21 </div> 21 </div>
22 <label for="project" class="col-sm-1 control-label text-right">项目名:</label> 22 <label for="project" class="col-sm-1 control-label text-right">项目名:</label>
23 <div class="col-sm-2 form-inline"> 23 <div class="col-sm-2 form-inline">
24 - <input type="text" class="form-control" id="project" name="project" value="<?php if (!empty($gets['project'])){ echo $gets['project'];} ?>" autocomplete="off"> 24 + <input type="text" class="form-control" id="project" placeholder="项目关键字" name="project" value="<?php if (!empty($gets['project'])){ echo $gets['project'];} ?>" autocomplete="off">
25 </div> 25 </div>
26 <label for="model" class="col-sm-1 control-label text-right">型号:</label> 26 <label for="model" class="col-sm-1 control-label text-right">型号:</label>
27 <div class="col-sm-2 form-inline"> 27 <div class="col-sm-2 form-inline">
28 - <input type="text" class="form-control" id="model" name="model" value="<?php if (!empty($gets['model'])){ echo $gets['model'];} ?>" autocomplete="off"> 28 + <input type="text" class="form-control" id="model" placeholder="型号关键字" name="model" value="<?php if (!empty($gets['model'])){ echo $gets['model'];} ?>" autocomplete="off">
29 </div> 29 </div>
30 <label for="status" class="col-sm-1 control-label text-right">状态:</label> 30 <label for="status" class="col-sm-1 control-label text-right">状态:</label>
31 <div class="col-sm-2 form-inline"> 31 <div class="col-sm-2 form-inline">
@@ -42,11 +42,11 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title; @@ -42,11 +42,11 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = $this-&gt;title;
42 <div class="form-group col-sm-12"> 42 <div class="form-group col-sm-12">
43 <label for="production" class="col-sm-1 control-label text-right">生产日期:</label> 43 <label for="production" class="col-sm-1 control-label text-right">生产日期:</label>
44 <div class="col-sm-2 form-inline"> 44 <div class="col-sm-2 form-inline">
45 - <input type="text" class="form-control" id="production" name="production" value="<?php if (!empty($gets['production'])){ echo $gets['production'];} ?>" autocomplete="off"> 45 + <input type="text" class="form-control" id="production" placeholder="生产日期关键字" name="production" value="<?php if (!empty($gets['production'])){ echo $gets['production'];} ?>" autocomplete="off">
46 </div> 46 </div>
47 <label for="manufacture" class="col-sm-1 control-label text-right">厂商:</label> 47 <label for="manufacture" class="col-sm-1 control-label text-right">厂商:</label>
48 <div class="col-sm-2 form-inline"> 48 <div class="col-sm-2 form-inline">
49 - <input type="text" class="form-control" id="manufacture" name="manufacture" value="<?php if (!empty($gets['manufacture'])){ echo $gets['manufacture'];} ?>" autocomplete="off"> 49 + <input type="text" class="form-control" id="manufacture" name="manufacture" placeholder="厂商关键字" value="<?php if (!empty($gets['manufacture'])){ echo $gets['manufacture'];} ?>" autocomplete="off">
50 </div> 50 </div>
51 <label for="mac" class="col-sm-1 control-label text-right">MAC地址:</label> 51 <label for="mac" class="col-sm-1 control-label text-right">MAC地址:</label>
52 <div class="col-sm-2 form-inline"> 52 <div class="col-sm-2 form-inline">
app-ht/modules/home/controllers/WelcomeController.php
@@ -2,8 +2,9 @@ @@ -2,8 +2,9 @@
2 2
3 namespace app\ht\modules\home\controllers; 3 namespace app\ht\modules\home\controllers;
4 4
  5 +use Yii;
5 use app\ht\controllers\BaseController; 6 use app\ht\controllers\BaseController;
6 - 7 +use domain\manufacturer\ManufacturerRepository;
7 class WelcomeController extends BaseController 8 class WelcomeController extends BaseController
8 { 9 {
9 /** 10 /**
@@ -11,6 +12,18 @@ class WelcomeController extends BaseController @@ -11,6 +12,18 @@ class WelcomeController extends BaseController
11 */ 12 */
12 public function actionIndex() 13 public function actionIndex()
13 { 14 {
14 - return $this->render("index"); 15 + $user = Yii::$app->user->identity;
  16 + $username = $user->username;
  17 + if ($user->is_manufacture) {
  18 + $manufacturer = ManufacturerRepository::findOne(['sys_user_id' => $user->username]);
  19 + if ($manufacturer) {
  20 + $username = $manufacturer->name;
  21 + }
  22 +
  23 + }
  24 + $params = [
  25 + 'username' => $username
  26 + ];
  27 + return $this->render("index", $params);
15 } 28 }
16 } 29 }
17 \ No newline at end of file 30 \ No newline at end of file
app-ht/modules/home/views/welcome/index.php
@@ -28,6 +28,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = &#39;欢迎&#39;; @@ -28,6 +28,6 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = &#39;欢迎&#39;;
28 <div class="panel panel-default"> 28 <div class="panel panel-default">
29 <div class="panel-body"> 29 <div class="panel-body">
30 <div class="image"><img src="<?php echo Url::to('@web/images/error-logo.png'); ?>"/></div> 30 <div class="image"><img src="<?php echo Url::to('@web/images/error-logo.png'); ?>"/></div>
31 - <div class="welcome-text"><h1>欢迎 <?= Yii::$app->user->identity->username ?> 使用管理后台</h1></div> 31 + <div class="welcome-text"><h1>欢迎 <?= $username ?> 使用管理后台</h1></div>
32 </div> 32 </div>
33 </div> 33 </div>
app-ht/modules/project/controllers/ProjectController.php
@@ -184,7 +184,7 @@ class ProjectController extends BaseController @@ -184,7 +184,7 @@ class ProjectController extends BaseController
184 } 184 }
185 185
186 /** 186 /**
187 - * 导出厂商数据 187 + * 导出项目数据
188 * @return string 188 * @return string
189 */ 189 */
190 public function actionExport() 190 public function actionExport()
app-ht/views/dashboard/index.php
1 <?php 1 <?php
2 2
3 use yii\helpers\Url; 3 use yii\helpers\Url;
4 - 4 +use domain\manufacturer\ManufacturerRepository;
5 $this->title = '欢迎'; 5 $this->title = '欢迎';
6 $this->params['breadcrumbs'][] = '欢迎'; 6 $this->params['breadcrumbs'][] = '欢迎';
7 ?> 7 ?>
@@ -28,6 +28,17 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = &#39;欢迎&#39;; @@ -28,6 +28,17 @@ $this-&gt;params[&#39;breadcrumbs&#39;][] = &#39;欢迎&#39;;
28 <div class="panel panel-default"> 28 <div class="panel panel-default">
29 <div class="panel-body"> 29 <div class="panel-body">
30 <div class="image"><img src="<?php echo Url::to('@web/images/error-logo.png'); ?>"/></div> 30 <div class="image"><img src="<?php echo Url::to('@web/images/error-logo.png'); ?>"/></div>
31 - <div class="welcome-text"><h1>欢迎 <?= Yii::$app->user->identity->username ?> 使用OTA管理后台</h1></div> 31 + <div class="welcome-text"><h1>欢迎 <?php
  32 + $user = Yii::$app->user->identity;
  33 + $username = $user->username;
  34 + if ($user->is_manufacture) {
  35 + $manufacturer = ManufacturerRepository::findOne(['sys_user_id' => $user->id]);
  36 + if ($manufacturer) {
  37 + $username = $manufacturer->name;
  38 + }
  39 +
  40 + }
  41 + echo $username;
  42 + ?> 使用OTA管理后台</h1></div>
32 </div> 43 </div>
33 </div> 44 </div>
app-ht/views/layouts/routes.php
@@ -49,31 +49,6 @@ if (isset($user-&gt;is_manufacture) &amp;&amp; $user-&gt;is_manufacture == 1) { @@ -49,31 +49,6 @@ if (isset($user-&gt;is_manufacture) &amp;&amp; $user-&gt;is_manufacture == 1) {
49 ] 49 ]
50 ], 50 ],
51 [ 51 [
52 - 'path' => '/device',  
53 - 'label' => '序列号',  
54 - 'routes' => [  
55 - [  
56 - 'path' => '/device',  
57 - 'redirect' => '/device/device/index'  
58 - ],  
59 -  
60 - ['label' => '序列号管理', 'path' => '/device/device/index'],  
61 - ['label' => '授权失败管理', 'path' => '/device/device/auth-fail-index'],  
62 - ['label' => '创建序列号', 'path' => '/device/device/create-device'],  
63 - ]  
64 - ],  
65 - [  
66 - 'path' => '/upgrade',  
67 - 'label' => '版本',  
68 - 'routes' => [  
69 - [  
70 - 'path' => '/upgrade',  
71 - 'redirect' => '/upgrade/upgrade/index'  
72 - ],  
73 - ['label' => '版本管理', 'path'=> '/upgrade/upgrade/index'],  
74 - ]  
75 - ],  
76 - [  
77 'path' => '/project', 52 'path' => '/project',
78 'label' => '项目', 53 'label' => '项目',
79 'routes' => [ 54 'routes' => [
@@ -107,6 +82,31 @@ if (isset($user-&gt;is_manufacture) &amp;&amp; $user-&gt;is_manufacture == 1) { @@ -107,6 +82,31 @@ if (isset($user-&gt;is_manufacture) &amp;&amp; $user-&gt;is_manufacture == 1) {
107 ] 82 ]
108 ], 83 ],
109 [ 84 [
  85 + 'path' => '/device',
  86 + 'label' => '序列号',
  87 + 'routes' => [
  88 + [
  89 + 'path' => '/device',
  90 + 'redirect' => '/device/device/index'
  91 + ],
  92 +
  93 + ['label' => '序列号管理', 'path' => '/device/device/index'],
  94 + ['label' => '授权失败管理', 'path' => '/device/device/auth-fail-index'],
  95 + ['label' => '创建序列号', 'path' => '/device/device/create-device'],
  96 + ]
  97 + ],
  98 + [
  99 + 'path' => '/upgrade',
  100 + 'label' => '版本',
  101 + 'routes' => [
  102 + [
  103 + 'path' => '/upgrade',
  104 + 'redirect' => '/upgrade/upgrade/index'
  105 + ],
  106 + ['label' => '版本管理', 'path'=> '/upgrade/upgrade/index'],
  107 + ]
  108 + ],
  109 + [
110 'path' => '/datas', 110 'path' => '/datas',
111 'label' => '数据', 111 'label' => '数据',
112 'routes' => [ 112 'routes' => [
common/config/params.php
@@ -11,5 +11,9 @@ return [ @@ -11,5 +11,9 @@ return [
11 'url' => 'https://kingboard-prod.oss-cn-shenzhen.aliyuncs.com', 11 'url' => 'https://kingboard-prod.oss-cn-shenzhen.aliyuncs.com',
12 'styleUrl' => 'https://kingboard-prod.oss-cn-shenzhen.aliyuncs.com' 12 'styleUrl' => 'https://kingboard-prod.oss-cn-shenzhen.aliyuncs.com'
13 ], 13 ],
14 - 'UPGRADE_FILE_FROM' => 'FROM_ECS' 14 + 'UPGRADE_FILE_FROM' => 'FROM_ECS',
  15 + 'AUTH_DEVICE_RSA_PKCS_1' => [
  16 + 'PRIVATE' => require(__DIR__ . '/rsa/privateKey.php'),
  17 + 'PUBLIC' => require(__DIR__ . '/rsa/publicKey.php')
  18 + ]
15 ]; 19 ];
common/config/rsa/privateKey.php 0 → 100644
@@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
  1 +<?php
  2 +return "-----BEGIN RSA PRIVATE KEY-----
  3 +MIICXQIBAAKBgQDKdPhKQl9BGPtHXDjjqH3LztTkyJoJUOUQcggCPVa4HWkNCqRj
  4 +2j7Kd+5C+i+TuFuqiWL32KKrDlm3kSFY8zW3VyUyqpJm/vgWgZDA+uGGTBsF6L38
  5 +GVa5d1XHtWCmIp0QBxDo0cz9VFzxvwQCsC7g3RiXxzMBzH/rtFw0BlWf6wIDAQAB
  6 +AoGBAIRn/V4rjDp5yRTBdp9FOYhKK6e4ni0Lj9OykBRO42EkMukJlbuMJ1apGtUI
  7 +5Ia6opCkq2ombzRp/Tj1nJac8PpdKNz5iuRSpNxpjNOwY3goRYjg8St5o8U2ZVyP
  8 +Buvli+Ew8NkQxU2MNcUiyShXfKunaVlvHT7qtgmggX2jCmUxAkEA9wPKu3ddzRax
  9 +bfBuCTMXpjhop+rQQzmZsceltekbEDZ2QzFRQerKDZX1EypfXcPN3OkGgQRbkkvB
  10 +QfHXXsA9+QJBANHSQPJ4Fj+IfUs8z1B2dTg4ddqTiNoUB0a5telxQR0qQ9j4FiC7
  11 +z61Sg/IhWkJEivnNBfMvqJY9JZmJXaktlgMCQQDq3P8hGhDlFMOlXaqyMpM054OS
  12 +zTAyCw14vPRxr2+dDbuKjdTOERkGq+N20p4UgD0345TcjTEoO8FIG1OE8tK5AkBC
  13 +4XwmTbT5x234v4dtpHS02PpoE8L5kIzJNIURxjH1M/WwgVO8V2FZZAX+9japDOQn
  14 +v/x3ied5DECh8jFSrd81AkAFrBlfAwUWJXM5yT1f0S6VjuXHJx47oljEJTEgFWKE
  15 +2xHfk3V92zvNFGE95jDHq6CY6kxNSE1pF+u2uFVnV9sm
  16 +-----END RSA PRIVATE KEY-----";
0 \ No newline at end of file 17 \ No newline at end of file
common/config/rsa/publicKey.php 0 → 100644
@@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
  1 +<?php
  2 +return "-----BEGIN PUBLIC KEY-----
  3 +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDKdPhKQl9BGPtHXDjjqH3LztTk
  4 +yJoJUOUQcggCPVa4HWkNCqRj2j7Kd+5C+i+TuFuqiWL32KKrDlm3kSFY8zW3VyUy
  5 +qpJm/vgWgZDA+uGGTBsF6L38GVa5d1XHtWCmIp0QBxDo0cz9VFzxvwQCsC7g3RiX
  6 +xzMBzH/rtFw0BlWf6wIDAQAB
  7 +-----END PUBLIC KEY-----";
0 \ No newline at end of file 8 \ No newline at end of file
common/exts/RSACrypt.php
@@ -4,30 +4,6 @@ namespace common\exts; @@ -4,30 +4,6 @@ namespace common\exts;
4 4
5 class RSACrypt 5 class RSACrypt
6 { 6 {
7 -  
8 - public static $private_key = "-----BEGIN RSA PRIVATE KEY-----  
9 -MIICXQIBAAKBgQCpS7mxdU6svbDcs10qbq9f9t5D4yfqC1jLmZD3GDD4D/8TbNkf  
10 -vcYDvde6nyPRSxrnzl9YmZhJKlP2iCIwdwwmW6yulXZyvPurfN/1AJt4JYDxnN/q  
11 -u1bSG5DZMribLsR2dlfA5J0D6lQ7g40eSgp4D6UWy8ezLy6UWFQCrnUHEQIDAQAB  
12 -AoGAQCQeoKtvOWdNIPEb9T2mWFdx8oqXzsapx8nQ8K1LsFBvNe7hfHMsGLLOjzhI  
13 -G7223eiEm07mMaJF2XvOaEpSYX/qQ1LZRSdBrzCec1lcDbB95dcRg9NmgBuCpUxE  
14 -3SGYm3VB8rurfsrRUUYoIbjWz8qyuIGdMbaNkHG/CpnUYpkCQQDfWYDYtQ3DxCt+  
15 -JBoLfuCykk8+nIV12CIYb023naoR2s/aQQRk9BkGCkDrdOAgZAN3BGOHYseKAfTP  
16 -nARDzfiDAkEAwgtYfgCDTOfW5/kJK1lZO21CdCCZnePwGYmWDLPzNiJIn8k0U6Ig  
17 -9GmxG+0GKzY71XO8W3Nh18ilZbX9dYel2wJASQ+AJGNlc0pyZ7rrgiMo4YEWxwZw  
18 -adIfpRqTs6KxhVGseFqYU2W94cns3pjG0BGnSIF5BUp8t1pYeKkyg/OWfQJBAK1w  
19 -mq41IycQaoR5kfqPKDT32dgWc3gvDqKk2duM1KzkQ+meXAkM90u/VLDTURo6pYyK  
20 -oCdVoHTRQRUCcAQnNNUCQQCO/zDRaY+5ssjPqj77eJqWfAhtbSDRRw+NurmUSas1  
21 -FT1cD5nil+uT48bIRoC5nk/XWfvAvMg/Yw5bslGUNx7f  
22 ------END RSA PRIVATE KEY-----";  
23 -  
24 - public static $public_key = "-----BEGIN PUBLIC KEY-----  
25 -MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCpS7mxdU6svbDcs10qbq9f9t5D  
26 -4yfqC1jLmZD3GDD4D/8TbNkfvcYDvde6nyPRSxrnzl9YmZhJKlP2iCIwdwwmW6yu  
27 -lXZyvPurfN/1AJt4JYDxnN/qu1bSG5DZMribLsR2dlfA5J0D6lQ7g40eSgp4D6UW  
28 -y8ezLy6UWFQCrnUHEQIDAQAB  
29 ------END PUBLIC KEY-----";  
30 -  
31 private $pubkey; 7 private $pubkey;
32 private $privkey; 8 private $privkey;
33 9
@@ -39,19 +15,8 @@ y8ezLy6UWFQCrnUHEQIDAQAB @@ -39,19 +15,8 @@ y8ezLy6UWFQCrnUHEQIDAQAB
39 function __construct($privateKey = null, $publicKey = null) 15 function __construct($privateKey = null, $publicKey = null)
40 { 16 {
41 // 获得资源类型公钥和私钥, 17 // 获得资源类型公钥和私钥,
42 - if ($publicKey) {  
43 - $_publicKey = $publicKey;  
44 - } else {  
45 - $_publicKey = self::$public_key;  
46 - }  
47 -  
48 - if ($privateKey) {  
49 - $_privateKey = $privateKey;  
50 - } else {  
51 - $_privateKey = self::$private_key;  
52 - }  
53 - $this->privkey = openssl_pkey_get_private($_privateKey);  
54 - $this->pubkey = openssl_pkey_get_public($_publicKey); 18 + $this->privkey = openssl_pkey_get_private($privateKey);
  19 + $this->pubkey = openssl_pkey_get_public($publicKey);
55 } 20 }
56 21
57 /** 22 /**
domain/device/Device.php
@@ -63,7 +63,7 @@ class Device @@ -63,7 +63,7 @@ class Device
63 'status' => $status, 63 'status' => $status,
64 'has_re_auth' => $hasReAuth, 64 'has_re_auth' => $hasReAuth,
65 'apply_at' => $applyAt, 65 'apply_at' => $applyAt,
66 - 'auth_at' => time(), 66 + //'auth_at' => time(),
67 ]; 67 ];
68 68
69 return self::create($item); 69 return self::create($item);
@@ -140,7 +140,7 @@ class Device @@ -140,7 +140,7 @@ class Device
140 $e->message = '授权成功, 重复授权'; 140 $e->message = '授权成功, 重复授权';
141 $e->success = true; 141 $e->success = true;
142 $e->status = 4; 142 $e->status = 4;
143 - } else{ 143 + } else {
144 $deviceModel->status = DeviceStatus::HAS_AUTH; 144 $deviceModel->status = DeviceStatus::HAS_AUTH;
145 $deviceModel->auth_at = time(); 145 $deviceModel->auth_at = time();
146 if ($deviceModel->save()){ 146 if ($deviceModel->save()){
@@ -201,9 +201,15 @@ class Device @@ -201,9 +201,15 @@ class Device
201 $e->message = '授权失败,系统异常'; 201 $e->message = '授权失败,系统异常';
202 return $e; 202 return $e;
203 } 203 }
  204 + // 测试代码
  205 + if (strpos($deviceId, 'FAILDEVICE') === false) {
  206 + $status = DeviceStatus::HAS_AUTH;
  207 + } else {
  208 + $status = DeviceStatus::FAIL_AUTH;
  209 + }
204 $newDeviceModel->device_id = $deviceId; 210 $newDeviceModel->device_id = $deviceId;
205 - $newDeviceModel->status = DeviceStatus::HAS_AUTH;  
206 - $newDeviceModel->apply_at = $tt ; 211 + $newDeviceModel->status = $status;
  212 + $newDeviceModel->apply_at = $tt;
207 $newDeviceModel->auth_at = $tt; 213 $newDeviceModel->auth_at = $tt;
208 if ($newDeviceModel->save()) { 214 if ($newDeviceModel->save()) {
209 $e->message = '授权成功'; 215 $e->message = '授权成功';
@@ -214,6 +220,14 @@ class Device @@ -214,6 +220,14 @@ class Device
214 $e->message = '授权失败,系统异常'; 220 $e->message = '授权失败,系统异常';
215 $e->status = 8; //系统异常 221 $e->status = 8; //系统异常
216 } 222 }
  223 + /* 测试代码*/
  224 + if (DeviceStatus::FAIL_AUTH == $status) {
  225 + $e->message = '授权失败,系统异常';
  226 + $e->success = false;
  227 + $e->serial_no = '';
  228 + $e->status = 8;
  229 + $e->mac = '';
  230 + }
217 231
218 return $e; 232 return $e;
219 } 233 }