Post ton services.yml svp
Version imprimable
Post ton services.yml svp
alors, voici le service.yml:
je precise que netbeans me souligne en rouge:Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 parameters: # developpement_cartopli.example.class: Developpement\CartopliBundle\Example services: # developpement_cartopli.example: # class: %developpement_cartopli.example.class% # arguments: [@service_id, "plain_value", %parameter%] ldap_user_provider: class: Developpement\CartopliBundle\Security\User\LdapUserProvider user.security.authentication.provider: class: Developpement\CartopliBundle\Security\Authentication\Provider\AuthProvider arguments: ["", %kernel.cache_dir%/security/nonces] user.security.authentication.listener: class: Developpement\CartopliBundle\Security\Firewall\AuthListener arguments: [@security.context, @security.authentication.manager, @security.authentication.session_strategy, @security.http_utils, @logger, "", @kernel] tags: - { name: monolog.logger, channel: security }
avec ceci d’écrit :Code:class: Developpement\CartopliBundle\Security\Firewall\AuthListener
je sais pas si c'est normal ou non...Citation:
ScannerException while scanning for the next token we had this found character @(64) that cannot start any token
Et voici mon listener:
l'erreur sur le navigateur: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
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 <?php namespace Developpement\CartopliBundle\Security\Firewall; use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationSuccessHandler; use Symfony\Component\Security\Http\Authentication\DefaultAuthenticationFailureHandler; 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\Exception\ProviderNotFoundException; 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 Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface; use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface; use Symfony\Component\HttpKernel\HttpKernelInterface; use Developpement\CartopliBundle\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, $logger, $options = array(), $httpKernel) { parent::__construct( $securityContext, $authenticationManager, $sessionStrategy, $httpUtils, "user", new DefaultAuthenticationSuccessHandler($httpUtils, $options), new DefaultAuthenticationFailureHandler($httpKernel, $httpUtils, $options), array_merge(array('username_parameter' => '_username', 'password_parameter' => '_password', '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;} } ?>
merci de votre aideCode: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
Choco7
Quelle version de Symfony utilises-tu ?
La mienne, c'est la 2.1.7
Et j'ai vu ici
https://github.com/fabpot/Silex/issues/431
une erreur qui ressemble à un bug corrigé.
la mienne est : 2.1.6
Tu pense que ce serai a cause de ca?
Je vien de passer a la 2.1.7 et pas de changement, l'erreur est encore la :/
L'argument qui pose maintenant problème est celui en rouge j'ai rajouté un var_dump($options);Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $logger, $options = array(), $httpKernel) { var_dump($options); exit; parent::__construct( $securityContext, $authenticationManager, $sessionStrategy, $httpUtils, "user", new DefaultAuthenticationSuccessHandler($httpUtils, $options), new DefaultAuthenticationFailureHandler($httpKernel, $httpUtils, $options), array_merge(array('username_parameter' => '_username', 'password_parameter' => '_password', 'intention' => 'authenticate', 'post_only' => true, ), $options)
exit;
Pour voir si le paramètre $options est bien un array
Les grands esprits se rencontre ^^
J'ai fais exactemment la meme chose a l'instant, et $option est un string :/
je sais pas si c'est un bon moyen de résoudre ce probleme, mais en faisant:
je n'ai plus aucune erreur, mais je sais pas si ca vas pas provoquer des erreur pour la suite :/Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, HttpUtils $httpUtils, $logger, $options = array(), $httpKernel) { $options=array(); parent::__construct( $securityContext, $authenticationManager, $sessionStrategy, $httpUtils, "user", new DefaultAuthenticationSuccessHandler($httpUtils, $options), new DefaultAuthenticationFailureHandler($httpKernel, $httpUtils, $options), array_merge(array('username_parameter' => '_username', 'password_parameter' => '_password', 'intention' => 'authenticate', 'post_only' => true, ), $options) ); }
Dans mon $options, j'ai
Ce paramètre est défini dans "security.yml"Code:
1
2 array(1) {["failure_path"]=>string(13) "/logouterreur"}
Le tiens doit être égal à "".
Peut-être un test sur $options avant de le forcer à array()
Maintenant à vérifier que l'authentification fonctionne.
a quoi sert le faillure path?
et ton chemin /logouterreur
et est defini ou?
merci de ton aide:)
Le failure path sert à rediriger l'utilisateur en cas d'échec de l'authentification
/logouterror est une route définie dans
Code:
1
2
3
4
5 # /app/config/routing.yml logouterreur_route: pattern: /logouterreur defaults: { _controller: CnamtsSecurityBundle:Default:erreur }
c'est au niveau du double guillement, la tu dois envoyer une array, alors "" c'est une string. En yml, je ne sais pas à quoi doit ressembler une array.Code:
1
2
3
4 user.security.authentication.listener: class: Developpement\CartopliBundle\Security\Firewall\AuthListener arguments: [@security.context, @security.authentication.manager, @security.authentication.session_strategy, @security.http_utils, @logger, "", @kernel] tags:
Moi non plus et dans les docs, ils mettent des "".
Après recherches, il semble qu'il faille mettre {} à la place des "" pour un tableau vide dans le services.yml
Merci pour l'information, même si je pense que le problème ne vient pas de là. Toutefois, on a plus de nouvelles :D
Pour ma part, je pense que ça vient de là car j'ai eu la même erreur en virant le failure_path de mon security.yml dans mes tests en version 2.1.
Et puis ça documente la "solution complète" :-)
Bonjour à tous, tout d'abord un grand merci à fatbob pour cette solution car c'est vraiment pas de la tarte :aie:
nous sommes désormais en version symfony 2.4.5 et c'est toujours autant le bagne pour créer une authentification custom :mrgreen:
je voulais savoir si vous aviez déjà étés confrontés à cette erreur en mettant en place cette solution?
voici mon sécurity.ymlCitation:
InvalidConfigurationException: Unrecognized options "login_path, check_path" under "security.firewalls.secured_area.my_user_factory"
et mon FactoryCode:
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 security: encoders: Acme\SecurityBundle\Security\User\User: plaintext role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] providers: user_provider: id: user_provider_service chain_provider: chain: providers: user_provider firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false login: pattern: ^/login$ security: false logout: pattern: ^/(logout$) security: false secured_area: pattern: ^/ my_user_factory: login_path: login check_path: /login_check logout: path: logout target: / #failure_path: /logouterreur #anonymous: ~ #http_basic: # realm: "Secured Demo Area" access_control: #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
en espérant que quelqu'un puisse m'aiderCode:
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 <?php namespace Acme\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; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FormLoginFactory; class UserFactory extends FormLoginFactory{ public function __construct(){ parent::__construct(); } public function getKey(){ return 'my_user_factory'; } protected function createAuthProvider(ContainerBuilder $container, $id, $config, $userProviderId){ $provider = 'security.authentication.provider.auth.'.$id; $container ->setDefinition($provider, new DefinitionDecorator('user.security.authentication.provider')) ->replaceArgument(0, new Reference($userProviderId)) ->replaceArgument(2, $id) ; return $provider; } public function getPosition() { return 'pre_auth'; } public function addConfiguration(NodeDefinition $node) {} }
Salut!
Je viens de reprendre le post aussi, et j'ai exactement la même erreur... je suis également en 2.4.5...