mirror of
https://github.com/pterodactyl/panel.git
synced 2026-11-30 11:25:52 -05:00
Changes the panel's default `Referrer-Policy` from `no-referrer-when-downgrade` to `strict-origin-when-cross-origin`. Prevents path and query string being sent in `Referrer`, so Google don't get our tasty password reset url tokens. Nothing I could find in panel reads a referrer cross-origin, and Wings checks Origin not Referrer.
35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pterodactyl\Tests\Pest\Integration\Http\ReferrerPolicyTest;
|
|
|
|
use Illuminate\Support\Facades\Route;
|
|
use Pterodactyl\Tests\Integration\Http\HttpTestCase;
|
|
|
|
uses(HttpTestCase::class);
|
|
|
|
test('password reset page sends the strict referrer policy', function () {
|
|
// This one route serves both the password reset email and the account setup email.
|
|
$response = $this->get(route('auth.reset', ['token' => 'secret-token']).'?email='.urlencode('user@example.com'));
|
|
|
|
$response->assertOk();
|
|
$response->assertHeader('Referrer-Policy', 'strict-origin-when-cross-origin');
|
|
});
|
|
|
|
test('an ordinary panel page sends the strict referrer policy', function () {
|
|
$response = $this->get(route('auth.login'));
|
|
|
|
$response->assertOk();
|
|
$response->assertHeader('Referrer-Policy', 'strict-origin-when-cross-origin');
|
|
});
|
|
|
|
test('a response that sets its own referrer policy keeps it', function () {
|
|
Route::get('/_test/own-referrer-policy', fn () => response('ok')->header('Referrer-Policy', 'no-referrer'));
|
|
|
|
$response = $this->get('/_test/own-referrer-policy');
|
|
|
|
$response->assertOk();
|
|
$response->assertHeader('Referrer-Policy', 'no-referrer');
|
|
});
|