Skip to content

Commit 6ac12fc

Browse files
committed
Disable integrity hashes by default, allow enabling with environment
Cloudflare auto-minifies our minified code even more (wat), which leads to issues with the resource hash, and then nothing loads. This is less likely to lead to support requests now.
1 parent de9ec1e commit 6ac12fc

File tree

2 files changed

+45
-33
lines changed

2 files changed

+45
-33
lines changed

app/Services/Helpers/AssetHashService.php

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,24 @@ public function integrity(string $resource): string
8282
*/
8383
public function css(string $resource): string
8484
{
85-
return '<link href="' . $this->url($resource) . '"
86-
rel="stylesheet preload"
87-
as="style"
88-
crossorigin="anonymous"
89-
integrity="' . $this->integrity($resource) . '"
90-
referrerpolicy="no-referrer">';
85+
$attributes = [
86+
'href' => $this->url($resource),
87+
'rel' => 'stylesheet preload',
88+
'as' => 'style',
89+
'crossorigin' => 'anonymous',
90+
'referrerpolicy' => 'no-referrer',
91+
];
92+
93+
if (config('pterodactyl.assets.use_hash')) {
94+
$attributes['integrity'] = $this->integrity($resource);
95+
}
96+
97+
$output = '<link';
98+
foreach ($attributes as $key => $value) {
99+
$output .= " $key=\"$value\"";
100+
}
101+
102+
return $output . '>';
91103
}
92104

93105
/**
@@ -100,9 +112,21 @@ public function css(string $resource): string
100112
*/
101113
public function js(string $resource): string
102114
{
103-
return '<script src="' . $this->url($resource) . '"
104-
integrity="' . $this->integrity($resource) . '"
105-
crossorigin="anonymous"></script>';
115+
$attributes = [
116+
'src' => $this->url($resource),
117+
'crossorigin' => 'anonymous',
118+
];
119+
120+
if (config('pterodactyl.assets.use_hash')) {
121+
$attributes['integrity'] = $this->integrity($resource);
122+
}
123+
124+
$output = '<script';
125+
foreach ($attributes as $key => $value) {
126+
$output .= " $key=\"$value\"";
127+
}
128+
129+
return $output . '></script>';
106130
}
107131

108132
/**

config/pterodactyl.php

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
| setup on the panel. When set to true, configurations stored in the
1111
| database will not be applied.
1212
*/
13-
'load_environment_only' => (bool) env('APP_ENVIRONMENT_ONLY', false),
13+
'load_environment_only' => (bool)env('APP_ENVIRONMENT_ONLY', false),
1414

1515
/*
1616
|--------------------------------------------------------------------------
@@ -102,29 +102,6 @@
102102
'high' => env('QUEUE_HIGH', 'high'),
103103
],
104104

105-
/*
106-
|--------------------------------------------------------------------------
107-
| Console Configuration
108-
|--------------------------------------------------------------------------
109-
|
110-
| Configure the speed at which data is rendered to the console.
111-
*/
112-
'console' => [
113-
'count' => env('CONSOLE_PUSH_COUNT', 10),
114-
'frequency' => env('CONSOLE_PUSH_FREQ', 200),
115-
],
116-
117-
/*
118-
|--------------------------------------------------------------------------
119-
| Daemon Connection Details
120-
|--------------------------------------------------------------------------
121-
|
122-
| Configuration for support of the new Golang based daemon.
123-
*/
124-
'daemon' => [
125-
'use_new_daemon' => (bool) env('APP_USE_NEW_DAEMON', false),
126-
],
127-
128105
/*
129106
|--------------------------------------------------------------------------
130107
| Task Timers
@@ -212,4 +189,15 @@
212189
'environment_variables' => [
213190
'P_SERVER_ALLOCATION_LIMIT' => 'allocation_limit',
214191
],
192+
193+
/*
194+
|--------------------------------------------------------------------------
195+
| Asset Verification
196+
|--------------------------------------------------------------------------
197+
|
198+
| This section controls the output format for JS & CSS assets.
199+
*/
200+
'assets' => [
201+
'use_hash' => env('PTERODACTYL_USE_ASSET_HASH', false),
202+
],
215203
];

0 commit comments

Comments
 (0)