Compare commits
12 Commits
fdb75e4888
...
cssupdate
| Author | SHA1 | Date | |
|---|---|---|---|
| 5fde7159e0 | |||
| a1be105c31 | |||
| f07741ff19 | |||
| e462b38ff9 | |||
| cd3f651a2a | |||
| e38446f3fd | |||
| 06b9d42ae4 | |||
| 99d78069d5 | |||
| 342a3754aa | |||
| 51e9c8ced1 | |||
| da8f204167 | |||
| 3fa3b8fb63 |
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
declare (strict_types = 1);
|
|
||||||
|
|
||||||
namespace app\command\OpenApiMgr;
|
|
||||||
|
|
||||||
use oauth\OAuthStorage;
|
|
||||||
use think\console\Command;
|
|
||||||
use think\console\Input;
|
|
||||||
use think\console\input\Argument;
|
|
||||||
use think\console\input\Option;
|
|
||||||
use think\console\Output;
|
|
||||||
|
|
||||||
class AddClient extends Command
|
|
||||||
{
|
|
||||||
protected function configure()
|
|
||||||
{
|
|
||||||
// 指令配置
|
|
||||||
$this->setName('OpenApiMgr:AddClient')
|
|
||||||
->addArgument('salt', Argument::OPTIONAL, "开放API的client_secret密钥的盐值")
|
|
||||||
->setDescription('开放API的client管理');
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function execute(Input $input, Output $output)
|
|
||||||
{
|
|
||||||
$salt = $input->getArgument('salt');
|
|
||||||
$salt = empty($salt) ? null : trim($salt);
|
|
||||||
|
|
||||||
// 指令输出
|
|
||||||
$oauth = new OAuthStorage($salt);
|
|
||||||
|
|
||||||
$client_id = random_str(13, 'all', 0);
|
|
||||||
$client_secret = random_str(32, 'all', 0);
|
|
||||||
|
|
||||||
$ok = $oauth->addClient($client_id, $client_secret, null);
|
|
||||||
if (!$ok) {
|
|
||||||
$output->writeln("添加失败");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$output->writeln("添加成功:\nClientID: {$client_id}\nClientSecret: {$client_secret}\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,12 +2,9 @@
|
|||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | 控制台配置
|
// | 控制台配置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
// 指令定义
|
// 指令定义
|
||||||
'commands' => [
|
'commands' => [
|
||||||
'data:migrate' => \app\command\DataMigration::class,
|
'data:migrate' => \app\command\DataMigration::class,
|
||||||
'openapi:addclient' => \app\command\OpenApiMgr\AddClient::class,
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user