feat/hosting-platform-upgrade #1

Merged
UkY merged 11 commits from feat/hosting-platform-upgrade into main 2026-09-06 20:36:21 +00:00
Owner
No description provided.
UkY added 11 commits 2026-09-06 20:36:13 +00:00
Six blockers found while auditing the platform, all in customer-facing paths:

- .reveal elements were hidden with opacity:0 and revealed by a .vis class
  that nothing ever added, so every element using it stayed invisible. On
  /reselling that hid six sections including both pricing cards. The hiding
  is now gated on .js-reveal, set by a new ScrollReveal component, so the
  content shows even when the observer never runs.

- Reseller portals hid their navigation below 768px with no replacement,
  leaving mobile visitors of every white-label storefront with no way to
  reach products, support or their account. Adds a menu with Escape and
  scroll-lock handling.

- orderProduct() in the reseller portal had try/finally and no catch: a
  dropped connection surfaced as an unhandled rejection and told the
  customer nothing. Failures now render inline instead of window.alert().

- Two more order paths (KVM table, KVM configurator) swallowed errors in
  empty catch blocks, so the button snapped back to its idle label as if
  the click had been ignored.

- The status page called getStatusReport() and getSession() unguarded, so a
  database outage took down the page whose purpose is to report it.

- The catalogue passed one shared loading boolean to every card, so a single
  click put the whole grid into "Bitte warten...". Tracks the pending plan id.

Also adds empty states for the KVM table and portal plans, role="alert" on
order errors, and a prefers-reduced-motion path for the reveal animations.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
FireAPI was assumed to expose backup listing only, and the code said so in a
comment. Probing the API shows otherwise: a route that exists answers
authorization_failed for a foreign VM, a route that does not answers
endpoint_not_found. By that test create, restore and delete all exist and
only rename is genuinely missing.

  GET    /vm/{id}/backup/list      authorization_failed  -> exists
  POST   /vm/{id}/backup/create    authorization_failed  -> exists
  POST   /vm/{id}/backup/restore   authorization_failed  -> exists
  DELETE /vm/{id}/backup/delete    authorization_failed  -> exists
  *      /vm/{id}/backup/rename    endpoint_not_found    -> absent

So customers can now create, restore and delete their own snapshots instead
of being told to contact support. Renaming is not offered: storing a label
in our own database would name the backup in Hosti and nowhere in the
customer's 24fire account, which is worse than not having the button.

The backup id travels in the request body — no path variant resolves.

Notes on the implementation:

- A 'view' share may list backups but not create, restore or delete them.
  Restoring destroys everything written since the snapshot, so it is not a
  read operation by any reading of the word.
- Restore and delete are confirmed inline, showing the snapshot's own
  timestamp and naming what is lost, rather than through window.confirm.
- Slot limits are only pre-checked when the plan reports a slot count;
  otherwise FireAPI's own refusal is surfaced verbatim.
- Descriptions are accepted at creation time, the only point at which the
  API allows one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Billing enforcement ran inside the request path of the dashboard, /api/orders
and the webhooks, throttled to once a minute per process. That made
suspensions, grace periods and deletions depend on somebody browsing the
site: a quiet weekend meant unpaid servers kept running, and a busy hour
meant every visitor paid for a global sweep over the same rows.

Payment reminders had the same shape of problem from the other side. They
existed only as an admin button that mailed every matching customer on each
click, so in practice nobody was reminded of anything.

Adds POST /api/internal/cron, guarded by INTERNAL_CRON_TOKEN, which runs:

  billing.expire     suspend overdue orders, start grace, purge expired
  provision.process  work the provisioning queue
  billing.notify     due reminders (7d, 1d), paused notice, final warning

Each task is isolated so one failure does not stop the others, and a partial
failure answers 500 so the scheduler can alert on it.

Deduplication: billing_notifications records (order, kind, due_at) and the
unique index makes the claim atomic, so a five-minute cron does not re-mail
the same customer and two overlapping runs cannot both send. The due date is
part of the key, so next month's cycle sends a fresh reminder. A failed send
releases the claim, otherwise an unconfigured mail provider would burn every
reminder on the first run.

The request-path sweep stays as a fallback but stands down once it sees a
recent successful scheduler run, so a correctly configured deployment stops
paying for it while an unconfigured one still works.

A scheduler that stops firing is invisible by nature, so scheduler_runs
records every run and the status page reports it: over 20 minutes is
degraded, over an hour is an outage.

Also corrects the README, which still documented SumUp and VyPay webhooks
that no longer exist, and now states plainly that orders do not auto-renew.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Four gaps that a German hosting shop cannot really ship without:

Password reset. There was no recovery path at all — a forgotten password
meant contacting support or losing the account. Tokens are 32 bytes of CSPRNG
output stored as a SHA-256 hash, so a leaked backup does not hand out working
reset links, and issuing one invalidates any earlier unused token.

The reset had to solve a subtler problem: sessions are stateless JWTs, so
"log everyone out" has nothing to delete. The sessions table in the schema is
dead code, never read or written. Adds users.sessions_valid_from as a cutoff
checked in getSession(), so a reset actually ends the sessions of whoever
knew the old password instead of leaving their cookie valid for another week.

Email verification. Nothing proved an address was reachable, which matters
when invoices and maintenance notices go there. Deliberately not a gate on
logging in: locking someone out of an account they just paid for because a
mail was slow costs more than the fake signups it prevents. Existing accounts
are backfilled as verified so the migration cannot lock out current customers.

Terms consent. Registration recorded no acceptance of the AGB or privacy
policy. Adds a required checkbox with links, the § 356 Abs. 4 BGB notice about
provisioning starting immediately, and — because a client-side checkbox proves
nothing afterwards — a stored timestamp plus the terms version in force at the
time.

Login throttling. Login had no rate limiting whatsoever: passwords could be
guessed as fast as bcrypt would answer. Limits by IP and by account, since by
IP alone a botnet spreads the load and by account alone one client can walk
through many accounts. The per-account rule is deliberately looser than the
per-IP one, because any account lockout can be turned into a denial of
service against a known customer. Checked before the bcrypt compare so a
blocked caller costs nothing, kept in the database rather than process memory
(which resets on deploy and is not shared between containers), and it fails
open so a broken limiter cannot take down the login page.

Also removes eleven [v0] debug log lines from the register route that printed
customer names and addresses on every signup, and stops echoing raw error
messages — database and provider internals were being returned to the client.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Generated artefact, already tracked in the repository.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The dashboard used four of Pterodactyl's client endpoints — details,
resources, websocket and power — so anything real meant leaving for the
Pterodactyl panel, which rather defeats the point of a white-label front end.

Adds the rest:

- File manager: browse, edit, rename, delete, create folders, compress and
  decompress, upload and download. Downloads and uploads use a signed URL
  straight to the daemon, so a multi-gigabyte world file never streams
  through this process. Editing is capped at 512 KB — the panel will happily
  return a 2 GB file, which would arrive in the browser as a string and take
  the tab with it.
- Backups: create, restore, delete, lock and download, with restore confirmed
  inline against the snapshot's own timestamp.
- Subusers: invite by e-mail with three permission presets rather than thirty
  checkboxes. The permission list is validated server-side against a fixed
  set — Pterodactyl accepts arbitrary strings, so an unchecked list would let
  a caller grant themselves anything the panel supports.
- Schedules: presets for the common cases (nightly restart, six-hourly) plus
  the task, created together so nobody ends up with a timer that fires and
  does nothing. A failed task creation rolls the schedule back.
- Databases: create, rotate password, delete. A 'view' share sees that a
  database exists but never its credentials.
- Startup variables: the Minecraft version, the jar, the player cap — the
  settings that otherwise arrive as support tickets. Only variables the egg
  marks editable can be written.
- SFTP details, stating plainly that the password is the panel account's own
  and that we do not store it, rather than showing an empty field.

Security fix found while wiring this up: the existing power and command
routes checked only that a share existed, not what it permitted, so a
read-only share could stop the server or run any console command — up to
wiping the world. Both now require write access, as do all the new routes,
through one shared resolveGameServerAccess helper rather than the check being
copied into each file where one would eventually be forgotten.

File paths from the client are normalised against traversal before reaching
the panel, and file names are stripped to a bare name.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
SEO. The shop had no sitemap, no robots.txt, no OpenGraph tags and no
structured data — for a site whose pages are largely price comparisons that
is the cheapest available win, because Product/Offer markup is what puts a
price into the search result rather than a bare link. All of it is generated
from lib/plans.ts, so it cannot drift from what the pages actually show. Only
bookable plans are marked in stock; advertising availability for a plan that
cannot be ordered is what gets structured data ignored.

robots.txt excludes the dashboards, the order flow and the token-carrying
auth pages, and also the reseller storefronts under /portal — those are other
people's brands and should rank on their own domains, not as duplicate
content under ours.

Destructive actions. KVM reinstall and admin user deletion were guarded by
window.confirm, a single OK button on operations that respectively wipe a
machine and cascade through orders, servers, invoices and wallet history with
no soft delete to undo it. Both now require typing the server or user name,
which cannot be dismissed by reflex.

Healthcheck. /api/status always answered 200, so a container healthcheck
against it would have passed while the app could not reach its database. It
now returns 503 when the database is unreachable, and the compose file uses
it. Deliberately keyed on the database alone: a missing scheduler is a real
problem that belongs in the report, but restarting the container does not fix
it and would produce a pointless restart loop.

Admin overview queried every user, order and server with no bound at all,
loading the entire history on each dashboard open. Capped at 2000 rows each —
high enough not to change day-to-day use, low enough that the query stops
scaling without limit. Real pagination is the eventual fix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three problems, all in code from this branch or exposed by it.

The websocket route handed out Wings credentials to any share. That socket is
not read-only: the same token that streams console output also accepts "send
command" and "set state", so a read-only share could have driven the server
through it and walked straight around the checks just added to /command and
/power. Pterodactyl scopes its tokens by the panel account's permissions, but
our shares are ours and the panel knows nothing about them, so the
restriction has to be applied here. The client now stops retrying on a 403
instead of backing off five times against a refusal that will not change.

getSession() had a fallback query, used when the reseller_portal_members join
fails, that did not select sessions_valid_from. On any installation taking
that path the session cutoff silently stopped being enforced — a password
reset would look like it worked while old cookies stayed valid for their full
seven days. The column is now selected there too; the last-resort query
predates it entirely, so the check simply does not fire.

The rate limiter passed its window and block durations as untyped parameters
into interval arithmetic. Postgres can resolve `$1 * INTERVAL '1 second'`
ambiguously depending on the inferred parameter type, so the casts are now
explicit rather than left to inference.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Registration was the one unthrottled auth endpoint. Each call creates a
database row and a Pterodactyl account and sends a verification mail, so
leaving it open is both a spam vector and a way to run up cost on the panel.

Five per hour per address, which a household behind one NAT will not reach.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
billing_notifications.due_at was nullable and part of the unique constraint
that ON CONFLICT relies on. Postgres treats NULLs in a unique constraint as
distinct from one another, so for any notification without a due date the
conflict never fired: the row inserted again on every run and the customer
was mailed every five minutes for as long as the order stayed in that state.

The expired notice is exactly that case — grace_until and next_payment_due_at
can both be absent — so this would have hit real customers on the first night
the cron ran, and it is the kind of failure people unsubscribe over.

due_at is now NOT NULL with an epoch sentinel for "no due date", which
collides with itself the way the deduplication needs. The runtime migration
backfills and tightens an existing table rather than only fixing new ones.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The file upload appended '&directory=' to the signed URL the panel returns.
That works only because the URL currently carries its token as a query
parameter; if it ever arrives without one the upload silently posts to a
malformed address. URL.searchParams decides the separator instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
UkY merged commit 07fb3a9510 into main 2026-09-06 20:36:21 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
UkY/hosti!1
No description provided.