Bonjour
Je rencontre un problème avec l'utilisation du bundle BeSimple\SsoAuthBundle.
Je souhaite mettre en place une authentification par serveur CAS.
Il n'y a pas de base de donnée contenant les utilisateurs (interne à l'application).
J'ai installé le bundle selon la procédure décrite.
voici mon security:
ma class user:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 security: encoders: #Symfony\Component\Security\Core\User\User: plaintext CASManager\SecurityBundle\Security\User\user: plaintext role_hierarchy: ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH] providers: in_memory: memory: users: user: { password: userpass, roles: [ 'ROLE_USER' ] } admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] } user_provider: id: user_provider_service firewalls: dev: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false login: pattern: ^/demo/secured/login$ security: false secured_area: pattern: ^/demo/secured/ form_login: check_path: _security_check login_path: _demo_login logout: path: _demo_logout target: _demo anonymous: ~ http_basic: realm: "Secured Demo Area" cas_firewall: #pattern: ^/admin/.*$ pattern: ^/ trusted_sso: manager: admin_sso #login_action: BeSimpleSsoAuthBundle:TrustedSso:login login_action: false #logout_action: BeSimpleSsoAuthBundle:TrustedSso:logout logout_action: false create_users: true created_users_roles: [ROLE_USER, ROLE_ADMIN] check_path: /client_check access_control: #- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
ma class userProvider
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php namespace CASManager\SecurityBundle\Security\User; use Symfony\Component\Security\Core\User\UserInterface; class User implements UserInterface { private $username; private $password; private $salt; private $roles; public function __construct($username, $password, $salt, array $roles) { $this->username = $username; $this->password = $password; $this->salt = $salt; $this->roles = $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 service:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php namespace CASManager\SecurityBundle\Security\User; use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\Exception\UnsupportedUserException; use BeSimple\SsoAuthBundle\Security\Core\User\UserFactoryInterface; use CASManager\SecurityBundle\Security\User\User; class UserProvider implements UserProviderInterface,UserFactoryInterface { /** * @var array */ private $roles; /** * Constructor. * * @param array $roles An array of roles */ public function __construct(array $roles = array()) { $this->roles = $roles; } /** * {@inheritdoc} */ public function loadUserByUsername($username) {echo "ok"; //return $this->spawnUser($username); $username = "toto"; $this->roles = ["toto","tata"]; return new User($username, null, null, $this->roles); } /** * {@inheritDoc} */ public function refreshUser(UserInterface $user) { if (!$user instanceof User) { throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($user))); } return $this->spawnUser($user->getUsername()); } /** * {@inheritDoc} */ public function supportsClass($class) { //return $class === 'Symfony\Component\Security\Core\User\User'; return $class === 'CASManager\SecurityBundle\Security\User\User'; } /** * Spawns a new user with given username. * * @param string $username * * @return \Symfony\Component\Security\Core\User\User */ private function spawnUser($username) { return new User($username, null, $this->roles, true, true, true, true); } public function createUser($username, array $roles, array $attributes) { return new User($username, null, $roles, true, true, true, true); } }
avec ça quand je test je suis bien rediriger vers le cas, puis ça tourne en boucle pour finir par me dire :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 services: user_provider_service: class: CASManager\SecurityBundle\Security\User\UserProvider arguments: [%ROLE_ADMIN%]
This webpage has a redirect loop
je tourne en rond depuis un moment j'avoue ne plus savoir ou cherchersi quelqu'un peut me filer un coup de main, une idée ou autre...
Partager