Skip to content
Snippets Groups Projects
Commit bb96aaac authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

Remove CustomUserRoles

This depends on tugraz specific things, so move it there.
parent a86d97ff
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,3 @@ services:
Dbp\Relay\BasePersonBundle\API\PersonProviderInterface:
'@Dbp\Relay\BasePersonConnectorLdapBundle\Service\LDAPPersonProvider'
Dbp\Relay\AuthBundle\API\UserRolesInterface:
'@Dbp\Relay\BasePersonConnectorLdapBundle\Service\CustomUserRoles'
<?php
declare(strict_types=1);
namespace Dbp\Relay\BasePersonConnectorLdapBundle\Service;
use Dbp\Relay\AuthBundle\API\UserRolesInterface;
class CustomUserRoles implements UserRolesInterface
{
private $ldap;
public function __construct(LDAPApi $ldap)
{
$this->ldap = $ldap;
}
public function getRoles(?string $userIdentifier, array $scopes): array
{
// Convert all scopes to roles, like the default
$roles = [];
foreach ($scopes as $scope) {
$roles[] = 'ROLE_SCOPE_'.mb_strtoupper($scope);
}
// In case we have a real user also merge in roles from LDAP
if ($userIdentifier !== null) {
$personRoles = $this->ldap->getRolesForCurrentPerson();
$roles = array_merge($roles, $personRoles);
$roles = array_unique($roles);
sort($roles, SORT_STRING);
}
return $roles;
}
}
......@@ -266,24 +266,6 @@ class LDAPApi implements LoggerAwareInterface, ServiceSubscriberInterface
return $postEvent->getPerson();
}
public function getRolesForCurrentPerson(): array
{
$person = $this->getCurrentPerson();
if ($person !== null) {
$roles = $person->getExtraData('ldap-roles');
if ($roles === null) {
return [];
}
assert(is_array($roles));
return $roles;
}
return [];
}
public function getPerson(string $id): Person
{
$id = str_replace('/people/', '', $id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment