AssumeRole.php
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace AlibabaCloud\Credentials\Request;
use AlibabaCloud\Credentials\Providers\Provider;
use AlibabaCloud\Credentials\RamRoleArnCredential;
use AlibabaCloud\Credentials\Signature\ShaHmac1Signature;
/**
* Retrieving assume role credentials.
*/
class AssumeRole extends Request
{
/**
* AssumeRole constructor.
*
* @param RamRoleArnCredential $arnCredential
*/
public function __construct(RamRoleArnCredential $arnCredential)
{
parent::__construct();
$this->signature = new ShaHmac1Signature();
$this->credential = $arnCredential;
$this->uri = $this->uri->withHost('sts.aliyuncs.com');
$this->options['verify'] = false;
$this->options['query']['RoleArn'] = $arnCredential->getRoleArn();
$this->options['query']['RoleSessionName'] = $arnCredential->getRoleSessionName();
$this->options['query']['DurationSeconds'] = Provider::DURATION_SECONDS;
$this->options['query']['AccessKeyId'] = $this->credential->getOriginalAccessKeyId();
$this->options['query']['Version'] = '2015-04-01';
$this->options['query']['Action'] = 'AssumeRole';
$this->options['query']['RegionId'] = 'cn-hangzhou';
if ($arnCredential->getPolicy()) {
$this->options['query']['Policy'] = $arnCredential->getPolicy();
}
}
}