From 811d71a97d322682f11f7791f5120def9e5ae761 Mon Sep 17 00:00:00 2001 From: Andreas Erhard Date: Thu, 28 Dec 2017 09:41:14 +0100 Subject: [PATCH] Pass firewall ID to created tokens The firewall ID must be passed to the UsernamePasswordToken (or its sub classes) to ensure that authentication is done correctly if there are multiple firewalls. Having a hard-coded value prevents the AuthProvider to be used for more than one firewall. In addition, a provider key which does not match the actual firewall ID prevents the Twig functions logout_path() and logout_url() to work correctly. --- Security/Authentication/AdAuthProvider.php | 4 ++-- Security/Factory/AdAuthFactory.php | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Security/Authentication/AdAuthProvider.php b/Security/Authentication/AdAuthProvider.php index 2ad8fde..9615470 100644 --- a/Security/Authentication/AdAuthProvider.php +++ b/Security/Authentication/AdAuthProvider.php @@ -67,14 +67,14 @@ public function authenticate(TokenInterface $token) $newToken = new $this->tokenClasses['faulty']( $User, $token->getCredentials(), - 'riper.security.active.directory.user.provider', + $this->config['firewall_id'], $User->getRoles() ); } else { $newToken = new $this->tokenClasses['standard']( $User, $token->getCredentials(), - 'riper.security.active.directory.user.provider', + $this->config['firewall_id'], $User->getRoles() ); } diff --git a/Security/Factory/AdAuthFactory.php b/Security/Factory/AdAuthFactory.php index eab9c2d..d1a43b2 100644 --- a/Security/Factory/AdAuthFactory.php +++ b/Security/Factory/AdAuthFactory.php @@ -22,13 +22,15 @@ public function __construct() * * @param ContainerBuilder $container * @param string $id The unique id of the firewall - * @param array $config The options array for this listener + * @param array $config The options array for this listener * @param string $userProviderId The id of the user provider * * @return string never null, the id of the authentication provider */ protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId) { + $config['firewall_id'] = $id; + $providerId = 'security.authentication.provider.riper.active_directory.' . $id; $container ->setDefinition(