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);
$this->log->info(__CLASS__.':'.__FUNCTION__.':'.json_encode($res));
return $this->return->success();
$this->log->info(__CLASS__.':'.__FUNCTION__.':授权oss信息:'.json_encode($res));
return $this->return->success('success');
}
}

View File

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