Commit Graph
84 Commits
Author SHA1 Message Date
robert dennis 01787b8c22 theme platform 2026-10-12 08:15:15 -04:00
subway 8e07ac97ab Fix a few API authorization gaps (#7273)
## Fixes
- An application key with only `users` write could create a root admin
or change an admin's password. Touching root admins now needs a key with
write on everything.
- An admin's account key could read node config (including the Wings
token) and create deploy tokens. Those admin endpoints now need a panel
session, and the application config endpoint no longer accepts account
keys. `wings configure` with an application key still works.

The email enumeration issue I originally had here is already covered by
#7259, so I dropped it.

Added tests for each. Full test suite, phpstan and pint pass. Checked
the node config page and auto-deploy in the admin UI still work.
2026-10-12 05:42:35 -04:00
robert dennis 6a654e6091 deployable node filters 2026-10-12 05:18:59 -04:00
robert dennis 1866ce9bfa action validation: rest 2026-10-12 05:18:58 -04:00
robert dennis 987eab6f72 drop json guard 2026-10-12 05:18:57 -04:00
robert dennis ae296bda86 drop json aliases 2026-10-12 05:18:57 -04:00
robert dennis d823ff24cd typed request input 2026-10-12 05:18:57 -04:00
robert dennis 38c17ce44d deployable nodes request 2026-10-12 05:18:56 -04:00
robert dennis 89d8cd8717 server startup action 2026-10-12 05:18:56 -04:00
robert dennis ac79b03483 server details action 2026-10-12 05:18:56 -04:00
robert dennis f4eee5e3f6 server build action 2026-10-12 05:18:56 -04:00
robert dennis b218339495 server create action 2026-10-12 05:18:56 -04:00
robert dennis 735308cdd3 database actions 2026-10-12 05:18:56 -04:00
robert dennis b91a8696b0 allocation actions 2026-10-12 05:18:56 -04:00
robert dennis e99328e03f node actions 2026-10-12 05:18:56 -04:00
robert dennis 25ec34fad4 user actions 2026-10-12 05:18:55 -04:00
robert dennis 66765eef2d location actions 2026-10-12 05:18:55 -04:00
robert dennis df428075c3 integer inputs 2026-10-12 05:18:54 -04:00
robert dennis feebc11056 boolean inputs 2026-10-12 05:18:54 -04:00
Sky Mulleyandrobert dennis 71dd1911a5 Implement native support for hooking into forms with extensions (#7256)
## Problem

Extensions can render content before and after most admin pages, but not
inside the forms on them. The only exception was
`panel.users.detail.form`, and it could only re-render or validate the
user's existing fields. An extension had no way to add a field of its
own, because the Panel's save requests had nowhere to carry the value
and nothing loaded it back.

## Changes

### Slots inside every admin form

The create and edit forms for users, nodes, servers, eggs, locations,
mounts and database hosts each render a slot inside the form, such as
`panel.servers.create.form` and `panel.servers.detail.details.form`. The
slot receives the native `form`, the form's `kind` (`admin.server`), and
`mode` (`'create'` or `'edit'`). Edit slots also receive the saved
`resource`. Contributed `form.AppField` controls share the form's
validation, pending state and submit action.

### Extension-owned fields

An extension registers fields in its provider:

```php
$this->registerFormFields('admin.user', ['plan' => ['required', 'in:free,pro']]);

$this->registerFormFields(
    'admin.node',
    ['region' => ['required', 'string', 'max:32']],
    fn (Node $node): array => ['region' => NodeRegion::for($node)],
    fn (Node $node, array $values) => NodeRegion::store($node, $values['region']),
);
```

The 14 create and update endpoints accept an optional `extensions: {
[extensionId]: { [field]: value } }` body field. Each extension's rules
are applied as `extensions.{id}.{field}`, and only when the request
includes that extension's values. The extension's `save` callback runs
in the same database transaction as the core change, so a failure rolls
both back.

Server creation is the exception. Wings reads the new server while
provisioning it, so extension values are saved after provisioning
succeeds, outside the transaction.

For Node updates when Wings is unreachable. `UpdateNode` saves the node
and then throws `ConfigurationNotPersistedException` as a warning. The
node controller defers that exception until the extension values are
saved, so the node update is no longer rolled back.

`GET /api/admin/extensions/forms/{form}/{id}` returns every extension's
current values. It requires the resource's read permission. Edit pages
fetch it before rendering the form, but only when an extension has
registered fields for that form; the bootstrap payload now lists them
per extension in `forms`.

For users and servers the callbacks are optional, and values are stored
in the extension's scoped settings (`settings()->forUser($user)`,
`forServer($server)`). Values are limited to strings, numbers, booleans,
`null`, or lists of strings and numbers, which keeps the OpenAPI schema
and generated types concrete.

A `load` callback that throws, or returns an invalid value, is recorded
against the extension in the `form` phase. The frontend then hides that
extension's slot contributions on the edit page, so a save cannot
overwrite its stored values with defaults. Fields of a disabled or
failed extension are neither validated, saved nor loaded.

---------

Co-authored-by: robert dennis <31261583+robertdrakedennis@users.noreply.github.com>
2026-10-09 01:26:45 -04:00
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00
Dane Everitt 895adb6e6f Ensure that a node description can be set, add additional test coverage (#5457) 2025-12-24 16:43:00 -08:00
Dane Everitt a264791fd4 Update PHP and JS dependencies to latest versions and modernize codebase (#5446) 2025-12-20 15:55:13 -08:00
Matthew Penner 8ca098940a chore: update composer dependencies (#5198)
Signed-off-by: Matthew Penner <me@matthewp.io>
2024-10-21 19:18:20 -06:00
Boy132 032e4f2e31 Apply node maintenance mode to servers (#4421) 2022-11-06 16:02:30 -07:00
Matthew PennerandDaneEveritt cbcf62086f Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
2022-10-14 10:59:20 -06:00
Devonte 9b531d5fd9 Include oom_disabled in application API request (#4262) 2022-10-04 20:12:46 -06:00
Boy132 025e1a21ae fix validator import (#4094) 2022-05-30 10:24:59 -04:00
DaneEveritt b051718afe Fix up API handling logic for keys and set a prefix on all keys 2022-05-22 19:03:51 -04:00
DaneEveritt e9c633fd03 Update transformers and controllers to no longer pull an API key attribute 2022-05-22 15:37:39 -04:00
DaneEveritt e313dff674 Massively simplify API binding logic
Changes the API internals to use normal Laravel binding which automatically supports nested-models and can determine their relationships. This removes a lot of confusingly complex internal logic and replaces it with standard Laravel code.

This also removes a deprecated "getModel" method and fully replaces it with a "parameter" method that does stricter type-checking.
2022-05-22 14:10:01 -04:00
DaneEveritt 97280a62a2 Add support for storing SSH keys on user accounts 2022-05-14 17:31:53 -04:00
Dane Everitt c449ca5155 Use more standardized phpcs 2021-01-23 12:33:34 -08:00
Dane Everitt ff21d83e2d Add endpoint to get all nodes meeting memory & disk requirements for a server; closes #1012 2021-01-10 13:08:43 -08:00
Dane Everitt 5763493c6c Allow setting the backup limit via the API; closes #2535 2020-10-17 14:23:00 -07:00
Dane Everitt 8697185900 Fix up database creation and handling code for servers; ref #2447 2020-10-11 11:59:46 -07:00
Dane Everitt cc6f98c0fd Replace all instances of 255 as a max length with 191; ref #2421 2020-09-26 16:29:26 -07:00
Dane Everitt 3c7ffaaadb Remove all references of packs from the Panel 2020-09-13 11:13:37 -07:00
Dane Everitt 2ed3763d21 cs fix 2020-06-28 15:43:44 -07:00
AreYouScared 2561e3e8d5 Add CPU Thread assignments
Added CPU Thread assignments for each server
2020-03-29 14:41:55 -04:00
Dane Everitt b99ea53ca1 Update client API endpoints to not use deprecated function 2019-09-05 21:41:20 -07:00
Dane Everitt 7543ef085d Format files 2019-09-05 21:32:57 -07:00
Dane Everitt 0d6cf54314 [L6] Update even more areas of codebase using custom model validation logic 2019-09-04 22:26:28 -07:00
Dane Everitt 81143e231a Merge branch 'master' into develop 2019-08-04 13:49:26 -07:00
Dane Everitt 81409947cf Default to OOM killer being disabled, add back configuration option per-server 2019-08-03 13:41:24 -07:00
Dane Everitt 2198269a65 Fix allocations requiring an alias when generated via API. 2019-08-03 13:03:54 -07:00
Dane Everitt a66d7a3417 Merge branch 'develop' into feature/vuejs 2019-03-09 11:19:07 -08:00
Dane Everitt 8253246955 Prevent an exception when creating databases with the same name on multiple hosts.
closes #1456
2019-03-02 15:31:25 -08:00
Dane Everitt 91c9cbba6f [#1500] Correctly require disk_overallocate 2019-03-02 14:48:05 -08:00
Dane Everitt 50c5ab92aa [#1500] Add support for limits array or base level values 2019-03-02 14:44:59 -08:00