Skip to content

[7.x] Add new Redirector::signedRoute(), Redirector::temporarySignedRoute() methods #32489

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

Merged
merged 2 commits into from
Apr 22, 2020
Merged

[7.x] Add new Redirector::signedRoute(), Redirector::temporarySignedRoute() methods #32489

merged 2 commits into from
Apr 22, 2020

Conversation

ryangjchandler
Copy link
Contributor

@ryangjchandler ryangjchandler commented Apr 22, 2020

This pull requests adds two new shortcut methods for redirecting to signed routes.

Currently, this can be achieved by:

redirect()->to(URL::signedRoute(...));

but this can get hard to read and isn't as fluent as the other methods, such as redirect()->route().

This PR adds support for the following:

redirect()->signedRoute($route, $parameters, $expiration, $status, $headers);

// and

redirect()->temporarySignedRoute($route, $expiration, $parameters, $status, $headers);

Happy to implement these as macros in userland, but I don't see why they're not implemented in core.

@taylorotwell
Copy link
Member

Curious about the use case on this. Signed URLs are usually used to confirm that your backend actually generated the URL. However, in this case, you are doing the redirecting so you ALREADY know that you generated the URL.

@ryangjchandler
Copy link
Contributor Author

ryangjchandler commented Apr 22, 2020

Curious about the use case on this. Signed URLs are usually used to confirm that your backend actually generated the URL. However, in this case, you are doing the redirecting so you ALREADY know that you generated the URL.

Yeah, understandably. I work for an insurance company where we have a public quote process.

When you start a quote you get taken to 'foo.com/quote/product/{order}' without any need for authentication. You can freely visit this page during the hour that the signed URL is valid. We're using the temporary signed URLs for these routes to ensure that customers can't enter or change the policy number and view another "in progress" quote for example.

When the user visits the next page, we redirect to the next page but still need that signature in place.

The original developer had used md5 hashes with a custom middleware for this, which had the same effect (with less security) as signed routes. Happy to provide more information.

@taylorotwell taylorotwell merged commit bead456 into laravel:7.x Apr 22, 2020
@ryangjchandler
Copy link
Contributor Author

Thanks 🙏🏼

@ryangjchandler ryangjchandler deleted the feature/redirect-signed-route branch April 22, 2020 14:04
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

Successfully merging this pull request may close these issues.

2 participants