feat : ali

This commit is contained in:
2024-11-06 15:00:26 +08:00
parent 534a044a26
commit 413a514986
2 changed files with 7 additions and 7 deletions

View File

@@ -93,7 +93,7 @@ class AliStsService extends BaseService
]; ];
$res = $this->getAliStsControls($payload); $res = $this->getAliStsControls($payload);
$this->log->info(__CLASS__.':'.__FUNCTION__.':'.json_encode($res)); $this->log->info(__CLASS__.':'.__FUNCTION__.':授权oss信息:'.json_encode($res));
return $this->return->success(); return $this->return->success('success');
} }
} }

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace App\Service\ServiceTrait\Common; namespace App\Service\ServiceTrait\Common;
use AlibabaCloud\SDK\Sts\V20150401\Models\AssumeRoleRequest; use AlibabaCloud\SDK\Sts\V20150401\Models\AssumeRoleRequest;
use AlibabaCloud\SDK\Sts\V20150401\Models\AssumeRoleResponse;
use AlibabaCloud\SDK\Sts\V20150401\Sts; use AlibabaCloud\SDK\Sts\V20150401\Sts;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions; use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use App\Lib\Log; use App\Lib\Log;
@@ -47,18 +48,17 @@ trait AliStsTrait
/** /**
* 获取 ali sts 控制器 * 获取 ali sts 控制器
* @param $payload * @param $payload
* @return Sts|void * @return AssumeRoleResponse
* @throws ContainerExceptionInterface * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface * @throws NotFoundExceptionInterface
*/ */
public function getAliStsControls($payload){ public function getAliStsControls($payload): AssumeRoleResponse
{
$client = $this->createClient(); $client = $this->createClient();
$assumeRoleRequest = new AssumeRoleRequest($payload); $assumeRoleRequest = new AssumeRoleRequest($payload);
$runtime = new RuntimeOptions([]); $runtime = new RuntimeOptions([]);
try { try {
$client->assumeRoleWithOptions($assumeRoleRequest, $runtime); return $client->assumeRoleWithOptions($assumeRoleRequest, $runtime);
return $client;
} catch (Exception $error) { } catch (Exception $error) {
$this->log->error(__CLASS__.'-'.__FUNCTION__.'-'.__LINE__.':'.$error->getMessage()); $this->log->error(__CLASS__.'-'.__FUNCTION__.'-'.__LINE__.':'.$error->getMessage());
} }