Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Commit 31cd247

Browse files
committed
merged branch bes89/update-access-check (PR #531)
This PR was submitted for the master branch but it was merged into the 2.1 branch instead (closes #531). Discussion ---------- fixed access check allow local link addresses and prevent access when XFF is set (the same as in app_dev.php) Commits ------- 4c34555 fixed access check: allow local link addresses and prevent access when XFF/HTTP_CLIENT_IP is set
2 parents 4960ae6 + 19dafe2 commit 31cd247

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

web/config.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
exit('This script cannot be run from the CLI. Run it from a browser.');
55
}
66

7-
if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
8-
'127.0.0.1',
9-
'::1',
10-
))) {
7+
// This check prevents access to configuration check that are deployed by accident to production servers.
8+
// Feel free to remove this, extend it, or make something more sophisticated.
9+
if (isset($_SERVER['HTTP_CLIENT_IP'])
10+
|| isset($_SERVER['HTTP_X_FORWARDED_FOR'])
11+
|| !in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1'))
12+
) {
1113
header('HTTP/1.0 403 Forbidden');
1214
exit('This script is only accessible from localhost.');
1315
}

0 commit comments

Comments
 (0)