lightSAML / SpBundle

SAML2 SP Symfony Bundle based on LightSAML
https://www.lightsaml.com/SP-Bundle/
MIT License
66 stars 70 forks source link

didn't create roles for SamlSpToken #57

Closed wax13003 closed 7 years ago

wax13003 commented 7 years ago

came with an error below:

Catchable Fatal Error: Argument 1 passed to LightSaml\SpBundle\Security\Authentication\Token\SamlSpToken::__construct() must be of the type array, null given,

When I checked the token created in SamlSpTokenFactory, didn't create the roles while that could not be null in SamlSpToken->__construct. Could anyone help me with this?

in vendor/lightsaml/sp-bundle/src/LightSaml/SpBundle/Security/Authentication/Token/SamlSpToken.php (line 27) SamlSpToken->__construct(null, 'main', array('username' => 'johndoe', 'email' => 'john@doe.com'), object(User)) in vendor/lightsaml/sp-bundle/src/LightSaml/SpBundle/Security/Authentication/Token/SamlSpTokenFactory.php (line 34) $token = new SamlSpToken( $user instanceof UserInterface ? $user->getRoles() : [], $providerKey, $attributes, $user ); return $token; }} SamlSpTokenFactory->create('main', array('username' => 'johndoe', 'email' => 'john@doe.com'), object(User), object(SamlSpResponseToken)) in vendor/lightsaml/sp-bundle/src/LightSaml/SpBundle/Security/Authentication/Provider/LightsSamlSpAuthenticationProvider.php (line 137) $result = $this->tokenFactory->create( $this->providerKey, $attributes, $user, $token ); } else { $result = new SamlSpToken( $user instanceof UserInterface ? $user->getRoles() : [], $this->providerKey, $attributes,

tmilos commented 7 years ago

Seems like your user getRoles is returning null and by UserInterface it should return array

wax13003 commented 7 years ago

Thanks, I have checked my User Entity, it has getRoles, and my user table has the roles field. May I know how to check the error with null given by getRoles? Thanks, I am following the steps by https://www.lightsaml.com/SP-Bundle/Getting-started/

/**

wax13003 commented 7 years ago

solved

tmilos commented 7 years ago

How? What was the problem?