Commit Graph
45 Commits
Author SHA1 Message Date
robert dennis e467b4b5ff review fixes 2026-11-05 15:10:39 -05:00
robert dennis f7aa208cab fix ci 2026-10-20 15:46:16 -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 cb9e2b4624 tag lookups 2026-10-12 05:18:59 -04:00
robert dennis 6a654e6091 deployable node filters 2026-10-12 05:18:59 -04:00
robert dennis 3ac8ecf098 seed egg tags 2026-10-12 05:18:59 -04:00
robert dennis ff9d59ee98 password rule code 2026-10-12 05:18:57 -04:00
robert dennis a84924539a server settings activity 2026-10-12 05:18:56 -04:00
robert dennis f8163159dd password rules 2026-10-12 05:18:56 -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 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
Sky Mulley 9c623eca71 port fix from 1.0 for display exceptions not returning correctly on api 2026-10-06 02:10:17 +01: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
Matthew Penner 8ca098940a chore: update composer dependencies (#5198)
Signed-off-by: Matthew Penner <me@matthewp.io>
2024-10-21 19:18:20 -06:00
Matthew Penner 1d38b4f0e2 Laravel 10 (#4706) 2023-02-23 12:30:16 -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
DaneEveritt 0621d8475d Return tests to passing now that we don't ignore a critical event... 2022-05-29 17:52:14 -04:00
DaneEveritt f7fc67344e Ensure tokens are found in the database using the expected logic 2022-05-22 16:05:58 -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 cca0010a00 Update egg import/update logic to all use the same pathwaus 2022-05-15 14:40:19 -04:00
DaneEveritt 34ffaebd3e Run cs-fix, ensure we only install dependency versions supporting 7.4+ 2022-05-04 19:01:29 -04:00
Paul Vogel dcbc1360a9 Improve test coverage for LocationController (#3779)
By adding tests for create, update, delete
2021-12-04 10:50:36 -08:00
Matthew Penner cc31a0a6d0 tests(integration): don't expect non-required fields 2021-11-15 11:29:22 -07:00
Charles Morgan 91ea0a4f41 Update core eggs to new docker yolk images (#3382) 2021-07-17 10:02:00 -07:00
Dane Everitt f5ca391400 Get tests back in working order 2021-04-17 12:02:08 -07:00
Dane Everitt c449ca5155 Use more standardized phpcs 2021-01-23 12:33:34 -08:00
Dane EverittandMatthew Penner a043071e3c Update to Laravel 8
Co-authored-by: Matthew Penner <me@matthewp.io>
2021-01-23 12:12:54 -08:00
Dane Everitt 12fe3f1a4e Fix failing integration tests 2020-09-13 12:02:39 -07:00
Dane Everitt 3c7ffaaadb Remove all references of packs from the Panel 2020-09-13 11:13:37 -07:00
devfrey 2fecba2500 Fix tests by adding required return type hints 2020-05-09 18:00:52 +02:00
Dane Everitt f9542c98e2 Fix tests broken by bad namespaces 2018-09-03 15:59:30 -07:00
Dane Everitt 565c5ddc52 Add integration tests for nests 2018-03-25 17:41:36 -05:00
Dane Everitt e8ea218f20 Add integration test for remaining application api user endpoints 2018-03-04 22:35:57 -06:00
Dane Everitt 9905358bc3 Add integration tests for remote user endpoint 2018-03-04 16:56:05 -06:00
Dane Everitt e2aa01c9cc First go at integration tests 2018-03-04 16:30:16 -06:00