Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass token with events, so events can use them for storing password #151

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions Event/LdapUserEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
namespace IMAG\LdapBundle\Event;

use Symfony\Component\EventDispatcher\Event;

use Symfony\Component\Security\Core\User\UserInterface;

use IMAG\LdapBundle\User\LdapUserInterface;

class LdapUserEvent extends Event
{
private $user;
private $token;

public function __construct(LdapUserInterface $user)
public function __construct(LdapUserInterface $user, $token = null)
{
$this->user = $user;
$this->token = $token;
}

public function getUser()
Expand All @@ -28,4 +27,14 @@ public function setUser($user)

return $this;
}

public function getToken()
{
return $this->token;
}

public function setToken($token)
{
$this->token = $token;
}
}
11 changes: 7 additions & 4 deletions Factory/LdapFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,23 @@ protected function getListenerId()
protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId)
{
$dao = 'security.authentication.provider.dao.'.$id;
$container
$definition = $container
->setDefinition($dao, new DefinitionDecorator('security.authentication.provider.dao'))
->replaceArgument(0, new Reference($userProviderId))
->replaceArgument(2, $id)
;

if ($container->hasDefinition('security.user_checker')) {
$definition
->replaceArgument(1, new Reference('security.user_checker.'.$id))
;
}
$provider = 'imag_ldap.security.authentication.provider.'.$id;
$container
->setDefinition($provider, new DefinitionDecorator('imag_ldap.security.authentication.provider'))
->replaceArgument(0, new Reference($userProviderId))
->replaceArgument(1, new Reference($dao))
->replaceArgument(4, $id)
;

;
return $provider;
}

Expand Down
4 changes: 2 additions & 2 deletions Provider/LdapAuthenticationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function authenticate(TokenInterface $token)
*/
private function ldapAuthenticate(LdapUserInterface $user, TokenInterface $token)
{
$userEvent = new LdapUserEvent($user);
$userEvent = new LdapUserEvent($user, $token);
if (null !== $this->dispatcher) {
try {
$this->dispatcher->dispatch(LdapEvents::PRE_BIND, $userEvent);
Expand All @@ -119,7 +119,7 @@ private function ldapAuthenticate(LdapUserInterface $user, TokenInterface $token
}

if (null !== $this->dispatcher) {
$userEvent = new LdapUserEvent($user);
$userEvent = new LdapUserEvent($user, $token);
try {
$this->dispatcher->dispatch(LdapEvents::POST_BIND, $userEvent);
} catch (AuthenticationException $authenticationException) {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "imag/ldap-bundle",
"name": "turnred/ldap-bundle",
"description": "LDAP Bundle for Symfony 2",
"homepage": "http://github.com/BorisMorel/LdapBundle",
"license": "CeCILL",
Expand Down