File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed
modules/backend/controllers Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 43
43
44
44
'url ' => 'http://localhost ' ,
45
45
46
+ /*
47
+ |--------------------------------------------------------------------------
48
+ | Trusted hosts
49
+ |--------------------------------------------------------------------------
50
+ |
51
+ | You may specify valid hosts for your application as an array or boolean
52
+ | below. This helps prevent host header poisoning attacks.
53
+ |
54
+ | Possible values:
55
+ | - `true`: Trust the host specified in app.url, as well as the "www"
56
+ | subdomain, if applicable.
57
+ | - `false`: Disable the trusted hosts feature.
58
+ | - array: Defines the domains to be trusted hosts. Each item should be
59
+ | a string defining a domain, IP address, or a regex pattern.
60
+ |
61
+ | Example of array values:
62
+ |
63
+ | 'trustedHosts' => [
64
+ | 'example.com', // Matches just example.com
65
+ | 'www.example.com', // Matches just www.example.com
66
+ | '^(.+\.)?example\.com$', // Matches example.com and all subdomains
67
+ | 'https://example.com', // Matches just example.com
68
+ | ],
69
+ |
70
+ | NOTE: Even when set to `false`, this functionality is explicitly enabled
71
+ | on the Backend password reset flow for security reasons.
72
+ */
73
+
74
+ 'trustedHosts ' => true ,
75
+
46
76
/*
47
77
|--------------------------------------------------------------------------
48
78
| Application Timezone
Original file line number Diff line number Diff line change 13
13
use ValidationException ;
14
14
use Exception ;
15
15
use Config ;
16
+ use October \Rain \Foundation \Http \Middleware \CheckForTrustedHost ;
16
17
17
18
/**
18
19
* Authentication controller
@@ -147,6 +148,20 @@ public function restore()
147
148
*/
148
149
public function restore_onSubmit ()
149
150
{
151
+ // Force Trusted Host verification on password reset link generation
152
+ // regardless of config to protect against host header poisoning
153
+ $ trustedHosts = Config::get ('app.trustedHosts ' , false );
154
+ if ($ trustedHosts === false ) {
155
+ $ hosts = CheckForTrustedHost::processTrustedHosts (true );
156
+
157
+ if (count ($ hosts )) {
158
+ Request::setTrustedHosts ($ hosts );
159
+
160
+ // Trigger the host validation logic
161
+ Request::getHost ();
162
+ }
163
+ }
164
+
150
165
$ rules = [
151
166
'login ' => 'required|between:2,255 '
152
167
];
You can’t perform that action at this time.
0 commit comments