Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Redirect to intended URL after successful login #79

Open
olivergernetzke-pon opened this issue Jan 4, 2024 · 3 comments
Open

Comments

@olivergernetzke-pon
Copy link

Hi there!

With standard Laravel authentication and login, I can redirect the user back to the page he originally wanted to go to
(with redirect()->intended(...)).
So for example:

How can we do that with this SAML2 package? Can we somehow put this into the relay_state_url?

Many thanks in advance for your help. I hope my question is clear. :)

@RaphMartinHEC
Copy link

Hello !
I have the same problem.
I can only redirect to a specific page (with the relay_state_url or 'loginRoute' => env('SAML2_LOGIN_URL'))
But with nothing put in one of these two, it loops over the {UUID}/login link

Thanks !

@RaphMartinHEC
Copy link

Hello again,

I solved the problem by modifying the Auth middleware like this:

protected function redirectTo(Request $request): ?string
{
    $UUID = 'my-UUID';
    $intendedUrl = $request->url();

    $fullUrl = "https://my.site/saml2/$UUID/login?returnTo=$intendedUrl";

    return url($fullUrl);
}

It can be done in less lines though

@jithintc
Copy link

jithintc commented Jul 10, 2024

This is the issue with the redirectUrl or the relaystate url is empty. You may have to use to saml_url('intented url') or saml_route('intented route') when providing the saml login url.
If you have a default url, add it to to the sam2 config file as loginRoute to avoid redirect loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants