attend je vais modifier le message avec tout mes fichier pour les mettre a jour avec ceux de maintenant
Version imprimable
attend je vais modifier le message avec tout mes fichier pour les mettre a jour avec ceux de maintenant
voila c'est fais comme ca tu peut voir mes fichier en cour
excuse moi mais je sais pas par rapport a ton authFactory je sais pas ce qui est necessaire pour moi :/
Salut
alors voici mes différents fichiers si cela peut aider:
mon AuthListener:
ma class UserCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 <?php //========================================================// //== ADManager - Système de Gestion LDAP pour Symphony2 ==// //== Viduc 2012 - viduc@sugarbox.fr ==// //========================================================// namespace ADManager\SecurityBundle\Security\Authentication\Firewall; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\Security\Http\Firewall\ListenerInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\SecurityContextInterface; use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface; use Symfony\Component\Security\Http\HttpUtils; use ADManager\SecurityBundle\Security\Authentication\Token\UserToken; class AuthListener extends AbstractAuthenticationListener { protected $securityContext; protected $authenticationManager; protected $httpUtils; public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $options = array()) { parent::__construct($securityContext, $authenticationManager, $sessionStrategy, $httpUtils, "user", array_merge(array( 'username_parameter' => '_username', 'password_parameter' => '_password', 'domaine_parameter' => '_domaine', 'intention' => 'authenticate', 'post_only' => true, ), $options)); } /** * Performs authentication. * * @param Request $request A Request instance * * @return TokenInterface The authenticated token, or null if full authentication is not possible * * @throws AuthenticationException if the authentication fails */ protected function attemptAuthentication(Request $request) { $username = trim($request->get($this->options['username_parameter'], null, true)); $password = $request->get($this->options['password_parameter'], null, true); $request->getSession()->set('USER', $username); $request->getSession()->set('PWD', $password); return $this->authenticationManager->authenticate(new UserToken($username, $password, $this->providerKey)); } public function getHttpUtils() {return $this->httpUtils;} public function setHttpUtils($httpUtils) {$this->httpUtils = $httpUtils;} }
ma class SecurityControllerCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 <?php //========================================================// //== ADManager - Système de Gestion LDAP pour Symphony2 ==// //== Viduc 2012 - viduc@sugarbox.fr ==// //========================================================// namespace ADManager\SecurityBundle\Security\User; use Symfony\Component\Security\Core\User\UserInterface; class User implements UserInterface { private $username; private $password; private $salt; private $roles; public function getRoles() {return $this->roles;} public function getPassword() {return $this->password;} public function getSalt() {return $this->salt;} public function getUsername() {return $this->username;} public function setRoles($roles) {$this->roles = $roles;} public function setPassword($password) {$this->password = $password;} public function setSalt($salt) {$this->salt = $salt;} public function setUsername($username) {$this->username = $username;} public function eraseCredentials() {} public function equals(UserInterface $user) { if (!$user instanceof User) {return false;} if ($this->password !== $user->getPassword()) {return false;} if ($this->getSalt() !== $user->getSalt()) {return false;} if ($this->username !== $user->getUsername()) {return false;} return true; } }
mon UserFactoryCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 <?php //========================================================// //== ADManager - Système de Gestion LDAP pour Symphony2 ==// //== Viduc 2012 - viduc@sugarbox.fr ==// //========================================================// namespace ADManager\SecurityBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\Security\Core\SecurityContext; class SecurityController extends Controller { public function loginAction() { $request = $this->getRequest(); $session = $request->getSession(); // get the login error if there is one $error = $session->get(SecurityContext::AUTHENTICATION_ERROR); $session->remove(SecurityContext::AUTHENTICATION_ERROR); return $this->render('ADManagerSecurityBundle:Security:login.html.twig', array( // last username entered by the user 'last_username' => $session->get(SecurityContext::LAST_USERNAME), 'error' => $error, )); } public function logoutAction() { return $this->render('ADManagerSecurityBundle:Security:logout.html.twig'); } }
mon routingCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 <?php //========================================================// //== ADManager - Système de Gestion LDAP pour Symphony2 ==// //== Viduc 2012 - viduc@sugarbox.fr ==// //========================================================// namespace ADManager\SecurityBundle\DependencyInjection\Security\Factory; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface; class UserFactory implements SecurityFactoryInterface { public function create(ContainerBuilder $container, $id, $config, $userProvider, $defaultEntryPoint) { $providerId = 'security.authentication.provider.user.'.$id; $container ->setDefinition($providerId, new DefinitionDecorator('user.security.authentication.provider')) ->replaceArgument(0, new Reference($userProvider)) ; $listenerId = 'security.authentication.listener.user.'.$id; $listener = $container->setDefinition($listenerId, new DefinitionDecorator('user.security.authentication.listener')); return array($providerId, $listenerId, $defaultEntryPoint); } public function getPosition() { return 'pre_auth'; } public function getKey() { return 'my_user_factory'; // Utilisée dans app/config/security.yml } public function addConfiguration(NodeDefinition $node) {} }
mon security_factories.ymlCode:
1
2
3
4
5
6
7
8
9
10
11 login: pattern: /login defaults: { _controller: ADManagerSecurityBundle:Security:login } login_check: pattern: /login_check logout: pattern: /logout defaults: { _controller: ADManagerSecurityBundle:Security:logout }
mon services.yml (du bundle)Code:
1
2
3
4
5
6 services: security.authentication.factory.user: class: ADManager\SecurityBundle\DependencyInjection\Security\Factory\UserFactory tags: - { name: security.listener.factory }
mon security.ymlCode:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 parameters: Roles_Groupes: ROLE_ADMIN: DSI_DSIWEB_ROLE_ADMIN ROLE_USER: DSI_DSIWEB_ROLE_USER ROLE_ADMINPRINTER: DSI_DSIWEB_ROLE_ADMINPRINTER ROLE_OPEPRINTER: DSI_DSIWEB_ROLE_OPEPRINTER ROLE_USERPRINTER: DSI_DSIWEB_ROLE_USERPRINTER services: user.security.authentication.provider: class: ADManager\SecurityBundle\Security\Authentication\Provider\AuthProvider arguments: ["", %kernel.cache_dir%/security/nonces] user.security.authentication.listener: class: ADManager\SecurityBundle\Security\Authentication\Firewall\AuthListener arguments: [@security.context, @security.authentication.manager, @security.authentication.session_strategy, @security.http_utils] tags: - { name: monolog.logger, channel: security } user_provider_service: class: ADManager\SecurityBundle\Security\User\UserProvider arguments: [@adldap, %Roles_Groupes%]
ma class adLdap est un service que créé pour mon module de connection ad (j'utilise une class récupéré ici)Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 security: factories: - "%kernel.root_dir%/../src/ADManager/SecurityBundle/Resources/config/security_factories.yml" encoders: #ymfony\Component\Security\Core\User\User: plaintext #ADManager\SecurityBundle\Entity\User: sha512 ADManager\SecurityBundle\Entity\User: plaintext role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] ROLE_ADMINPRINTER: ROLE_USER, ROLE_OPEPRINTER ROLE_OPEPRINTER: ROLE_USERPRINTER ROLE_USER: ROLE_USERPRINTER providers: user_provider: id: user_provider_service firewalls: login: pattern: ^/login$ security: false checkpoint: pattern: ^/ my_user_factory: true form_login: login_path: /login check_path: /login_check logout: path: /logout #target: / access_control: - { path: ^/DSI/printer/printer, roles: ROLE_OPEPRINTER } - { path: ^/DSI/printer/imprimer, roles: ROLE_USERPRINTER }
bonjour je vous informe de mon avancement, j'ai repris ce que avez fais Viduc, mais une chose ne passe pas, le listener et les services qui lui sont associer doivent être modifier apparemment depuis la version 2.1 de symfony, mais je ne sais pas comment les modifiers, AuthenticationSuccessHandlerInterface et AuthenticationFailureHandlerInterface doive surement être ajouter quelque par mais sais pas comment les ajouter :/
voici le message d'erreur:
merci encore de votre aide a tous; vraiment merci car je ne me sens plus seul sur le problème.Code:Catchable Fatal Error: Argument 6 passed to Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener::__construct() must implement interface Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface, array given, called in C:\wamp\www\Symfony\src\Developpement\CartopliBundle\Security\Firewall\AuthListener.php on line 37 and defined in C:\wamp\www\Symfony\vendor\symfony\symfony\src\Symfony\Component\Security\Http\Firewall\AbstractAuthenticationListener.php line 79
choco7
http://www.developpez.net/forums/d12...tion-complete/
Je me facilites la tache fatbob vient de répondre dans ce post à la problématique que tu as .
Merci fatbob
Oui, merci fatbob, et merci a toi et a tout ce qui mon aider je vous informe de mon avancé :))
j’obtiens cette erreur apres la reprise du topic de fatbob:
:/Code:Catchable Fatal Error: Argument 2 passed to Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler::__construct() must be an array, string given, called in C:\wamp\www\Symfony\src\Developpement\CartopliBundle\Security\Firewall\AuthListener.php on line 42 and defined in C:\wamp\www\Symfony\vendor\symfony\symfony\src\Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler.php line 40