workarea-commerce / workarea

Workarea is an enterprise-grade Ruby on Rails commerce platform
https://www.workarea.com
Other
327 stars 66 forks source link

Raise Error When URL Not Allowed Through Proxy #455

Closed tubbo closed 4 years ago

tubbo commented 4 years ago

The proxy in Commerce Cloud will return a 403 response with a special header when a request has not been allowed through. In this case, Workarea now raises an error describing the problem and how to go about solving it. This resolves an issue where previously, errors thrown as a result of a misconfigured proxy would be cryptic and hard to debug. With this more descriptive error, developers will be able to see from Sentry how they can resolve such a scenario.

Here's what someone might see if they trigger this error:

Dragonfly::Job::FetchUrl::ProxyError: Error fetching 'http://via.placeholder.com/350x150' with Dragonfly!

This URL is not allowed through the proxy, and therefore the
request was blocked by the Workarea Commerce Cloud firewall.

To allow the host through your proxy server, run the following
command on your local development workstation:

    workarea [qa|staging|production] edit proxy

Thanks for using Commerce Cloud, and keeping your Workarea
application safe.
tubbo commented 4 years ago

It should raise a ProxyError in the Sidekiq job as the CSV is being imported, so the user would not actually see anything.

As far as moving it to the plugin, I'm into that but I feel like if we're going to move this error over, we should just move the whole freedom patch into the plugin, as it's not relevant for any installation of Workarea that does not require a production server proxy.

bencrouse commented 4 years ago