nbgrp / onelogin-saml-bundle

OneLogin SAML Symfony Bundle
BSD 3-Clause "New" or "Revised" License
43 stars 13 forks source link

Is it possible to set returnTo? #26

Open jirinapravnik opened 1 year ago

jirinapravnik commented 1 year ago

Is it possible to set returnTo parametr via $_GET or something like that?

I have url /saml/login. I want to redirect always from page, where I click on login button. I would like to set something like /saml/login?returnTo=/account/me and after login (or logout) get to page /account/me etc.

slejnej commented 1 year ago

There is a workaround you could to on your side. When user clicks /saml/login you can save to session their current route. You can then extend the DefaultAuthenticationSuccessHandler if you don't have your own. Then load the route from session and return a RedirectResponse

a-menshchikov commented 1 year ago

@jirinapravnik hi! If your /account/me page there is behind the firewall that use this bundle, you'll be redirected for it automatically after successful log in. \Symfony\Component\Security\Http\Firewall\ExceptionListener persist the request URI at the moment when redirects you for login and then we pass this URI to the SAML server, which returns it in RelayState (if not, this URI will still be used by SamlAuthenticationSuccessHandler).