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