Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions web/specs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1090,11 +1090,11 @@ Save fetches the latest server and applies only the changes from the original ba

## Server security overrides (spec 030)

One shared editor, `SecurityAdvanced` (`web/src/components/SecurityAdvanced.tsx`), edits `spec.security` on a GameServer: `runAsUser`, `runAsGroup` and `fsGroup` (each a whole number 0 to 4294967295, or "use image default" where the image's own user is kept) and `volumeOwnershipCheck` (`EveryStart` or `OnlyWhenWrong`). It shows each module default from the template's `spec.security` next to the override, the desired and applied values and the `pending` flag from `status.security`, and a root-override notice. It exports `isValidSecurityId`, `securityOverrideCount` and `securityIsValid`. The operator decides what applies; the component only edits the spec. Unset fields are left out of the payload, and an empty override is omitted entirely.
One shared editor, `SecurityAdvanced` (`web/src/components/SecurityAdvanced.tsx`), edits `spec.security` on a GameServer: `runAsUser`, `runAsGroup` and `fsGroup` (each a whole number 0 to 4294967295, or "use image default" where the image's own user is kept) and `volumeOwnershipCheck` (`EveryStart` or `OnlyWhenWrong`). It shows each module default from the template's `spec.security` next to the override, the desired and applied values from `status.security`, and a root-override notice. A setting shows "Applied: X" once the server has an applied record, and "Next start: X" (the desired value) before it has ever started. The "Pending: X · applies on the next restart" chip appears only when an applied record exists and the desired value differs from it, so a server that has never started shows no Pending chip (FR-009). It exports `isValidSecurityId`, `securityOverrideCount` and `securityIsValid`. The operator decides what applies; the component only edits the spec. Unset fields are left out of the payload, and an empty override is omitted entirely.

Three places mount it:

- **Create server wizard** (`web/src/routes/CreateServer.tsx`, Configure step): an "Advanced" section below the other fields. The Configure step cannot continue while a typed value is not a valid ID (`securityDraftValid`). Its `server.security.*` refusals show as a "Not created: security settings refused" error with the API's message. The section is read-only when the session lacks `servers:security` (`can(me, "servers:security", ...)`).
- **Create server wizard** (`web/src/routes/CreateServer.tsx`, Configure step): an "Advanced" section below the other fields. The Configure step cannot continue while a typed value is not a valid ID (`securityDraftValid`). Picking a different template clears the overrides, since they were chosen (and any risky value confirmed) against the previous module. Its `server.security.*` refusals show as a "Not created: security settings refused" error with the API's message. The section is read-only when the session lacks `servers:security` (`can(me, "servers:security", ...)`).
- **Server Settings, Security section** (`web/src/routes/tabs/settings/Security.tsx`, `SecuritySection`; registered in `web/src/routes/tabs/Settings.tsx` as the `security` section, with `Lock` icon): it wraps `SecurityAdvanced` in the settings draft. The section is read-only without `servers:security`, and the tab's Save footer applies it like any other section. Saving a changed `runAsUser` or `runAsGroup` on a server whose `status.security.applied` is set (it has already started, so it has data) opens a confirmation (`needsFileAccessWarning`): files written earlier keep their old owner, and saving does not restart the server.
- **Cluster Security panel** (`web/src/components/clusters/SecuritySettingsPanel.tsx`, mounted in `ClusterConfiguration.tsx` for every cluster): the cluster-wide `allowRootOverrides` switch. Without `config:read` the section shows a no-permission note instead of the switch, and the switch is editable only with `config:manage`. It reads and writes `GET`/`PUT /security-settings?cluster=<id>` through `SecuritySettings` in `web/src/lib/endpoints.ts`. A 409 or the `server.cluster.security_settings_missing` message ID (or a response with `present: false`) shows a "Security settings missing" alert and disables the switch. Register Cluster (`RegisterClusterDialog.tsx`) has an optional control-plane namespace field (lowercase DNS label, default `gameplane`) sent as `controlPlaneNamespace` only when it differs from `gameplane`, and the cluster overview shows that namespace for remote clusters.

Expand Down
2 changes: 1 addition & 1 deletion web/src/components/SecurityAdvanced.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ describe("SecurityAdvanced", () => {
expect(screen.getByText("Next start: 0")).toBeInTheDocument();
expect(screen.getByText("Override")).toBeInTheDocument();
expect(screen.queryByText(/^Applied:/)).not.toBeInTheDocument();
expect(screen.getByText("Pending: 0 · applies on the next restart")).toBeInTheDocument();
expect(screen.queryByText(/^Pending:/)).not.toBeInTheDocument();
});

it.each<{ source: SecuritySource; value?: number; line: string; chip: string }>([
Expand Down
4 changes: 3 additions & 1 deletion web/src/components/SecurityAdvanced.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ function SettingStatus({ applied, desired }: { applied?: StatusEntry; desired?:
const shown = applied ?? desired;
if (shown === undefined) return null;
const shownText = entryText(intl, shown);
const pending = desired !== undefined && entryKey(desired) !== entryKey(applied);
// Pending means a saved change the running server has not applied yet, so a
// server that has never started (no applied record) shows none (FR-009).
const pending = applied !== undefined && desired !== undefined && entryKey(desired) !== entryKey(applied);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
return (
<div className="flex flex-wrap items-center gap-2 text-xs text-muted">
<span>
Expand Down
Loading