阿里云STS(Security Token Service)是阿里云提供的一种临时访问权限管理服务。RAM提供RAM用户和RAM角色两种身份。其中,RAM角色不具备永久身份凭证,而只能通过STS获取可以自定义时效和访问权限的临时身份凭证,即安全令牌(STS Token)。
Installing
composer require whereof/aliyun-sts -v
Example
$accessKeyID = '***********';
$accessKeySecret = "**********";
$roleArn = "acs:ram::****************:role/aliyunosstokengeneratorrole";
$sts = new \whereof\aliyun\Sts($accessKeyID, $accessKeySecret, $roleArn);
//RAM用户调用AssumeRole接口获取一个扮演RAM角色的临时身份凭证(STS Token)。该接口中RAM用户扮演的是可信实体为阿里云账号类型的RAM角色。https://help.aliyun.com/document_detail/28763.html
$sts->assumeRole($roleSessionName = 'alice', $durationSeconds = 3600);
//调用GetCallerIdentity接口获取当前调用者的身份信息。https://help.aliyun.com/document_detail/43767.html
$sts->getCallerIdentity();
//进行角色SSO时,通过调用AssumeRoleWithSAML接口,可以获取一个扮演该角色的临时身份凭证(STS Token)。https://help.aliyun.com/document_detail/109979.html
$sts->assumeRoleWithSAML($SAMLProviderArn,$RoleArn,$DurationSeconds,$Policy);