Open rp-eric opened 10 years ago
Good idea. I think supporting regexes here is a bit of an overkill. What about simply declaring with what string a valid URL has to begin? So, for instance putting http://example.com/apis/ would allow http://example.com/apis/something but not http://example.org/whatever.
Do you have time to create a PR? I’m pretty packed at the moment.
I have started work on this feature on the issue_14 branch on my fork. Let me know what you think.
Looks a bit more complicated than it would need to IMHO. I would simply (try to) load the config file directly in isUrlAllowed() instead of factoring that out, loading it globally and then passing it to isUrlAllowed(). I would also suggest to simply allow all URLs if no config file has been found instead of throwing an exception. Finally, I think a simple text file (allowed-hosts.conf) would be simpler than requiring this to be PHP.
Thoughts?
Hydra Console includes what amounts to a proxy server. Here is an example. To prevent abuse, you should be able to restrict the URIs the proxy server will accept. Typically you would restrict the domain to your service's server.
I suggest that URIs be restricted by a whitelist composed of regular expressions. This is a sketch of how the URI restriction would work.
The
$uriFilter
must be configurable. For simplicity, this variable can be defined as a PHP array in a separate config file. The config file can be included in a non-global scope. This is a sketch of how that would be done.This configuration file can be reused for other configuration options particular to the proxy server.