hslavich / OneloginSamlBundle

OneLogin SAML Bundle for Symfony
MIT License
149 stars 94 forks source link

Update SamlProvider.php #164

Closed balazs92117 closed 3 years ago

balazs92117 commented 3 years ago

Fixes hslavich#155 Fixes hslavich#148

If I update roles with setSamlAttributes it works well, the tokenFactory genereates the right token. But at the next page refresh it redirects back to login page. It's because of this: [2021-06-03T11:37:01.687883+02:00] security.DEBUG: Cannot refresh token because user has changed. {"username":"test","provider":"Symfony\Bridge\Doctrine\Security\User\EntityUserProvider"} [] [2021-06-03T11:37:01.688630+02:00] security.DEBUG: Token was deauthenticated after trying to refresh it. [] [] The token's roles and the saved User Entity's roles mismatching. But with this PR the User Entity is peristed after calling setSamlAttributes(), so at the next tokenrefresh it matches the previosly generated token.

a-menshchikov commented 3 years ago

@balazs92117 Thank you for PR.

Wrap persistence into if ($this->entityManager) and add the same code into \Hslavich\OneloginSamlBundle\Security\Http\Authenticator\SamlAuthenticator please.

balazs92117 commented 3 years ago

@a-menshchikov It's done.

a-menshchikov commented 3 years ago

@balazs92117 thanx! :+1: