Skip to content

Commit b1e6116

Browse files
Adding TRUSTED_HOST_PATTERNS support. Updating change log & readme.
1 parent 81d06d8 commit b1e6116

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

CHANGELOG.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi
44

55
## [Unreleased][unreleased]
66

7+
## [0.1.14] - 2022-01-21
8+
9+
### Changed
10+
11+
- Added TRUSTED_HOST_PATTERNS support.
12+
713
## [0.1.13] - 2022-01-20
814

915
### Fixed
@@ -101,8 +107,9 @@ Updates should follow the [Keep a CHANGELOG](https://keepachangelog.com/) princi
101107

102108
**Initial release!**
103109

104-
[unreleased]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.13...main
105-
[0.1.12]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.12...0.1.13
110+
[unreleased]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.14...main
111+
[0.1.14]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.13...0.1.14
112+
[0.1.13]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.12...0.1.13
106113
[0.1.12]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.11...0.1.12
107114
[0.1.11]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.10...0.1.11
108115
[0.1.10]: https://github.com/unleashedtech/dotenv-drupal/compare/0.1.9...0.1.10

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ configuration.
119119
* [SHIELD_MESSAGE](#shield_message)
120120
* [SITES](#sites)
121121
* [SOLR_URL](#solr_url)
122+
* [TRUSTED_HOST_PATTERNS](#trusted_host_patterns)
122123
* More configuration options coming soon!
123124

124125
#### DATABASE_URL
@@ -216,6 +217,9 @@ so the shorter DSN can be used.
216217

217218
Streamlined environment-dependent configuration of _one_ Solr core is supported at this time.
218219

220+
#### TRUSTED_HOST_PATTERNS
221+
A CSV list of patterns specifying [trusted hosts](https://www.drupal.org/docs/installing-drupal/trusted-host-settings#s-protecting-in-drupal-8).
222+
219223
#### Configuration Conclusion
220224
With these few Environment Variables, you will be able to configure Drupal in a streamlined
221225
fashion similar to the way Symfony is configured. Support for many more common Drupal features

src/Dotenv.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,8 @@ public function getConfig(): array
115115

116116
// Default to having shield enabled.
117117
if (isset($_SERVER['SHIELD'])) {
118-
$config['shield.settings']['shield_enable'] = (bool) $_SERVER['SHIELD'];
119-
}
120-
else {
118+
$config['shield.settings']['shield_enable'] = (bool)$_SERVER['SHIELD'];
119+
} else {
121120
$config['shield.settings']['shield_enable'] = TRUE;
122121
}
123122

@@ -272,6 +271,10 @@ public function getSettings(): array
272271
if (isset($_SERVER['HASH_SALT'])) {
273272
$settings['hash_salt'] = $_SERVER['HASH_SALT'];
274273
}
274+
if (isset($_SERVER['TRUSTED_HOST_PATTERNS'])) {
275+
$settings['trusted_host_patterns'] = explode(',', $_SERVER['TRUSTED_HOST_PATTERNS']);
276+
}
277+
275278
switch ($envName) {
276279
case 'dev':
277280
$settings['container_yamls'] = [
@@ -285,9 +288,7 @@ public function getSettings(): array
285288
$settings['hash_salt'] = 'foo';
286289
$settings['rebuild_access'] = FALSE;
287290
if (isset($_SERVER['VIRTUAL_HOST'])) {
288-
$settings['trusted_host_patterns'] = [
289-
$_SERVER['VIRTUAL_HOST'],
290-
];
291+
$settings['trusted_host_patterns'][] = $_SERVER['VIRTUAL_HOST'];
291292
}
292293
$settings['skip_permissions_hardening'] = TRUE;
293294
$settings['update_free_access'] = FALSE;

0 commit comments

Comments
 (0)