diff --git a/extensions/debug/CHANGELOG.md b/extensions/debug/CHANGELOG.md index 604c0d34dc..111b193a72 100644 --- a/extensions/debug/CHANGELOG.md +++ b/extensions/debug/CHANGELOG.md @@ -4,7 +4,7 @@ Yii Framework 2 debug extension Change Log 2.0.4 under development ----------------------- -- no changes in this release. +- Enh #7655: Added ability to filter access by hostname (thiagotalma) 2.0.3 March 01, 2015 diff --git a/extensions/debug/Module.php b/extensions/debug/Module.php index 3a6fa09b85..764392591d 100644 --- a/extensions/debug/Module.php +++ b/extensions/debug/Module.php @@ -30,6 +30,13 @@ class Module extends \yii\base\Module implements BootstrapInterface * by localhost. */ public $allowedIPs = ['127.0.0.1', '::1']; + /** + * @var array the list of hosts that are allowed to access this module. + * Each array element is a hostname that will be resolved to an IP address that is compared + * with the IP address of the user. A use case is to use a dynamic DNS (DDNS) to allow access. + * The default value is `[]`. + */ + public $allowedHosts = []; /** * @inheritdoc */ @@ -197,6 +204,12 @@ class Module extends \yii\base\Module implements BootstrapInterface return true; } } + foreach ($this->allowedHosts as $hostname) { + $filter = gethostbyname($hostname); + if ($filter === $ip) { + return true; + } + } Yii::warning('Access to debugger is denied due to IP address restriction. The requesting IP address is ' . $ip, __METHOD__); return false; }