Skip to content

Commit

Permalink
Grant API-mapped team members admin privileges
Browse files Browse the repository at this point in the history
  • Loading branch information
melegiul committed Nov 13, 2024
1 parent 5aea0bf commit 67c5a3a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Security/KeycloakAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ private function persistUser(User $user, ResourceOwnerInterface $keycloakUser):
$teams = $this->syncApiGroups($keycloakUser);
foreach ($teams as $team) {
$user->addTeam($team);
$team->addAdmin($user);
$this->em->persist($team);
}
break;
}
Expand All @@ -214,6 +216,10 @@ private function persistUser(User $user, ResourceOwnerInterface $keycloakUser):
return $user;
}

/**
* @param ResourceOwnerInterface $keycloakUser
* @return Collection<Team>
*/
private function syncApiGroups(ResourceOwnerInterface $keycloakUser): Collection {
try {
$userId = $keycloakUser->toArray()[$this->groupApiUserId];
Expand Down

0 comments on commit 67c5a3a

Please sign in to comment.