Ejemplo n.º 1
0
 public static function assumedRoles()
 {
     $c = new IamClient(['version' => 'latest', 'region' => 'us-east-1']);
     $username = $c->getUser()->search('User.UserName');
     $groups = $c->listGroupsForUser(['UserName' => $username])->search('Groups[].GroupName');
     $policies = [];
     foreach ($groups as $group) {
         $managedPolicies = $c->ListAttachedGroupPolicies(['GroupName' => $group])->search('AttachedPolicies[].PolicyArn');
         $policies = array_merge($policies, $managedPolicies);
     }
     $roles = [];
     foreach ($policies as $policy) {
         $version = $c->getPolicy(['PolicyArn' => $policy])->search('Policy.DefaultVersionId');
         $policyDoc = urldecode($c->getPolicyVersion(['PolicyArn' => $policy, 'VersionId' => $version])->search('PolicyVersion.Document'));
         $roles = array_merge($roles, self::getAssumedRoles($policyDoc));
     }
     return $roles;
 }
Ejemplo n.º 2
0
 /**
  * @return User
  */
 public function findCurrentUser()
 {
     $result = $this->iamClient->getUser();
     return new User($result->get('User'));
 }