Я удалось пройти аутентификацию через CAS с помощью связки: prayno. Мне удается успешно получить роли из базы данных через сущность и репозиторий. Но дело в том, что мне не удалось установить связь между ними.
Вот мой файл security.yaml:
Код: Выделить всё
security:
# https://symfony.com/doc/current/security.html#where-do-users-come-from- user-providers
providers:
cas:
id: prayno.cas_user_provider
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
logout: ~
guard:
authenticators:
- prayno.cas_authenticator
Код: Выделить всё
public function loadUserByUsername($username)
{
if ($username) {
$password = '...';
$salt = "";
$roles = ['ROLE_USER'];
return new CasUser($username, $password, $salt, $roles);
}
throw new UsernameNotFoundException(
sprintf('Username "%s" does not exist.', $username)
);
}
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/52476781/symfony-4-get-authentification-with-cas-and-roles-via-database[/url]
Мобильная версия