mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-25 10:40:16 +01:00
Redirect instead of 400 from file on wrong domain
Summary: We recently opted for 'security.alternate-file-domain' and we have some hotlinks to the original domain. Test Plan: Enabled 'security.alternate-file-domain', observed redirect. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3380
This commit is contained in:
parent
d814245eea
commit
66a300768a
1 changed files with 4 additions and 2 deletions
|
@ -34,9 +34,11 @@ final class PhabricatorFileDataController extends PhabricatorFileController {
|
|||
$request = $this->getRequest();
|
||||
|
||||
$alt = PhabricatorEnv::getEnvConfig('security.alternate-file-domain');
|
||||
$alt_domain = id(new PhutilURI($alt))->getDomain();
|
||||
$uri = new PhutilURI($alt);
|
||||
$alt_domain = $uri->getDomain();
|
||||
if ($alt_domain && ($alt_domain != $request->getHost())) {
|
||||
return new Aphront400Response();
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($uri->setPath($request->getPath()));
|
||||
}
|
||||
|
||||
$file = id(new PhabricatorFile())->loadOneWhere(
|
||||
|
|
Loading…
Add table
Reference in a new issue