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.
## Problem
`Tests\Integration\Console\SchedulerTest` (telemetry is scheduled and
sent only when enabled, dataset true) fails when the whole integration
suite runs, with `Failed asserting that actual size 22 matches expected
size 2`. It passes when the file is run on its own.
## Reproduction
Run `vendor/bin/pest tests/Integration` on a fresh checkout of the 2.0
development branch with the settings from `.env.ci` (it fails the same
way on Linux with PHP 8.3 and 8.4 against MariaDB 11 and MySQL 8, and on
Windows). Run `vendor/bin/pest
tests/Integration/Console/SchedulerTest.php` alone and it passes.
## Root cause
The test creates one node and then asserts that exactly two HTTP
requests were recorded: the telemetry request and the request for that
node. When the scheduler test runs inside the full suite, other
integration tests have already left committed node rows in the database
(21 nodes existed when the test ran). The telemetry job fetches system
information from every node, so each of those nodes adds another
request. Only the telemetry URL was faked, so the extra requests were
real outbound connection attempts to the random addresses of the
leftover factory nodes.
## Fix
* Fake every other URL with an empty successful response, so the test
can never make real network requests.
* Assert what the test is about, which is that exactly one telemetry
request is sent, instead of the total number of requests. The existing
assertion that the telemetry payload contains the created node is kept.
## Testing
* `vendor/bin/pest tests/Integration/Console/SchedulerTest.php` passes.
* The full `vendor/bin/pest tests/Integration` run no longer reports
this test as failed (on Windows the remaining failures there come from
missing `pdo_sqlite` and POSIX file modes and are unrelated).
## Compatibility considerations
Test only change. No application code, configuration or behaviour is
touched.
Fixes two SFTP lockout bugs:
- `ad374661f` moved the server lookup after the password check, so fake
server identifiers bypassed the rate limit.
- `24f340c9a` keyed the lockout on server + Wings IP, so anyone could
lock every user out of a server.
Unknown servers are now rejected before any credential check, and the
lockout is keyed on the normalised username + resolved server UUID.
This change applies a rate limit to account email changes to prevent
enumeration on the system. The throttle is applied at the account level.
Administrators can still update an account's email address manually to
bypass this restriction if/when necessary.
This is a partial implementation to begin moving towards stripe-style
identifiers for resources in the system. Any models with an existing
`uuid` column can easily be updated to return an identifier in the
format of `prfx_xyz` where `prfx` is a four character prefix, and `xyz`
is the UUID, encoded using base-32.
These are quite easy to use within the API layer because we just need to
do one quick transformation to extract the UUID for those models. This
PR implements that logic for servers in the `SubstituteClientBindings`
logic.
A future PR will need to come through and handle identifiers for models
that _don't_ currently use UUIDs for reference that we want to expose to
clients. In those cases it is easier to just generate base-32 encoded
UUID7s that get stored in the database and indexed. They follow the same
base approach, but you don't need to do any transformations in the code
(other than stripping the prefix, unless we decide to store the prefix).
There is also now a `PTERODACTYL_USE_SERVER_IDENTIFIERS` environment
variable, that when set to true, updates the front-end and API response
to use this new identifier in place of the `uuidShort` value.
This expands upon previous work done to better disconnect users from
SFTP when different events occur within Pterodactyl. This new logic also
accounts for password changes and their account being deleted entirely
from the system.
These events now trigger background jobs that will reach out to every
node they are associated with to ensure they're disconnected if
currently connected.