lightSAML / SpBundle

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

Fatal Error: redirectToRoute() not found #18

Closed INSEAD-asim closed 7 years ago

INSEAD-asim commented 8 years ago

Hi,

I am implementing sp-bundle in Symfony 2.3 project. It appears that this function was implemented in Symfony 2.6. Can you help?

FatalErrorException: Error: Call to undefined method LightSaml\SpBundle\Controller\DefaultController::redirectToRoute() in C:\DATA\Projects\PHP\Symfony2\Symfony2-LightSAML-SP\vendor\lightsaml\sp-bundle\src\LightSaml\SpBundle\Controller\DefaultController.php line 47

tmilos commented 8 years ago

Sorry about that, I missed it. In DefaultController lines using $this->redirectToRoute should be modified to use a Symfony 2.3 compatible way of redirection/creating path.

kidatsy commented 7 years ago

Ran into the same thing, and I'm dropping this here for anyone else who runs across it. The override was pretty simple. There are instructions here for overriding vendor bundles: http://symfony.com/doc/2.7/bundles/override.html (even though it's for 2.7, it should work for 2.3+ at least)

Since the basic setup for LightsamlSPBundle involves extending Entities and defining new Services anyway, might as well make a new Bundle that extends the base lightsaml Bundle, as outlined above.

Replace return $this->redirectToRoute(... with return $this->redirect($this->generateUrl(... in discoveryAction and loginAction.

Also make sure to copy over the Resources/config/routing.yml to your new bundle and point the routes for those two actions to your new controller's actions, and you should be set.

tmilos commented 7 years ago

Why wouldn't you make a pull request?

kidatsy commented 7 years ago

I did the override in the name of expediency, but can make a PR, too!

kidatsy commented 7 years ago

Here's the PR: https://github.com/lightSAML/SpBundle/pull/37

tmilos commented 7 years ago

Merged #37 and released with 1.0.5. Thanks for the PR