fix(wg): single audit per confirm action (no descriptor double-audit)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
feat/v1-foundation
boban 2026-06-21 01:00:26 +02:00
parent 7ccefa5890
commit 858a00955a
1 changed files with 12 additions and 26 deletions

View File

@ -80,12 +80,9 @@ class Index extends Component
'danger' => true, 'danger' => true,
'icon' => 'trash', 'icon' => 'trash',
'notify' => '', 'notify' => '',
'token' => ConfirmToken::issue( // No audit descriptor — the apply path (removePeer) audits, so the confirm modal
'wgPeerRemoved', // must NOT also audit (avoids a double audit row for one action).
['name' => $name], 'token' => ConfirmToken::issue('wgPeerRemoved', ['name' => $name]),
'wg.remove-peer',
$name,
),
], ],
); );
} }
@ -144,12 +141,7 @@ class Index extends Component
'danger' => ! $on, 'danger' => ! $on,
'icon' => 'shield', 'icon' => 'shield',
'notify' => '', 'notify' => '',
'token' => ConfirmToken::issue( 'token' => ConfirmToken::issue('wgGateToggle', ['on' => $on ? '1' : '0']),
'wgGateToggle',
['on' => $on ? '1' : '0'],
$on ? 'wg.gate-up' : 'wg.gate-down',
$on ? 'on' : 'off',
),
], ],
); );
} }
@ -198,12 +190,7 @@ class Index extends Component
'danger' => true, 'danger' => true,
'icon' => 'alert', 'icon' => 'alert',
'notify' => '', 'notify' => '',
'token' => ConfirmToken::issue( 'token' => ConfirmToken::issue('wgSetPort', ['port' => $this->newPort]),
'wgSetPort',
['port' => $this->newPort],
'wg.set-port',
$this->newPort,
),
], ],
); );
} }
@ -220,8 +207,10 @@ class Index extends Component
if (! $this->throttle()) { if (! $this->throttle()) {
return; return;
} }
$this->pendingId = $bridge->request('set-port', ['port' => (string) ($payload['params']['port'] ?? '')]); $port = (string) ($payload['params']['port'] ?? '');
$this->pendingId = $bridge->request('set-port', ['port' => $port]);
$this->pendingAction = 'set-port'; $this->pendingAction = 'set-port';
$this->audit('wg.set-port', $port);
$this->newPort = ''; $this->newPort = '';
} }
@ -241,12 +230,7 @@ class Index extends Component
'danger' => true, 'danger' => true,
'icon' => 'alert', 'icon' => 'alert',
'notify' => '', 'notify' => '',
'token' => ConfirmToken::issue( 'token' => ConfirmToken::issue('wgSetSubnet', ['subnet' => $this->newSubnet]),
'wgSetSubnet',
['subnet' => $this->newSubnet],
'wg.set-subnet',
$this->newSubnet,
),
], ],
); );
} }
@ -263,8 +247,10 @@ class Index extends Component
if (! $this->throttle()) { if (! $this->throttle()) {
return; return;
} }
$this->pendingId = $bridge->request('set-subnet', ['subnet' => (string) ($payload['params']['subnet'] ?? '')]); $subnet = (string) ($payload['params']['subnet'] ?? '');
$this->pendingId = $bridge->request('set-subnet', ['subnet' => $subnet]);
$this->pendingAction = 'set-subnet'; $this->pendingAction = 'set-subnet';
$this->audit('wg.set-subnet', $subnet);
$this->newSubnet = ''; $this->newSubnet = '';
} }