Take Pireon's webhooks: a deactivation or a revocation counts at once
Some checks failed
Tests / lint (push) Has been cancelled
Tests / test (push) Has been cancelled
Tests / test-postgres (push) Has been cancelled
Tests / mcp (push) Has been cancelled

Until now, an account switched off or a token revoked at the identity
server kept working here: bearer tokens until the introspection cache
ran out, panel sessions until they ended, and machine tokens for good,
as they only look at the local account.

POST /api/v1/webhooks/pireon takes user.deactivated (the account goes
inactive, which stops its machine tokens and the panel; its sessions
end and its cached tokens are forgotten) and token.revoked (sessions
and cached tokens go). Pireon signs each delivery with the secret of
the client that registered the webhook, so either PIREON_WEBHOOK_SECRET
(password client) or PIREON_REDIRECT_WEBHOOK_SECRET («Entrar con
Pireon») verifies it; with neither, the endpoint refuses everything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-16 17:01:57 +02:00
parent ec4f687ca8
commit d10ce1ca57
9 changed files with 361 additions and 0 deletions

View File

@@ -198,6 +198,27 @@ curl -X POST http://localhost:8000/api/v1/auth/token \
Es el mismo grant que usa el formulario del panel, así que
`PIREON_PASSWORD_GRANT=false` desactiva los dos a la vez.
### Webhooks de Pireon
Para que desactivar una cuenta o revocar un token en Pireon surta efecto al
instante, sin esperar al TTL de la caché:
1. Registra `https://tu-dominio/api/v1/webhooks/pireon` con los eventos
`user.deactivated` y `token.revoked` en el cliente de contraseña
(`POST /api/clients/{client}/webhooks` del servidor de identidad) y pon el
secret que devuelve en `PIREON_WEBHOOK_SECRET`.
2. Si usas el cliente de «Entrar con Pireon», registra el mismo webhook en él y
pon su secret en `PIREON_REDIRECT_WEBHOOK_SECRET`. Pireon firma cada aviso
con el secret del cliente que lo registró, y una revocación solo la avisa el
cliente que emitió el token.
`user.deactivated` desactiva la cuenta aquí (lo que corta también sus tokens de
máquina y el panel), cierra sus sesiones del panel (con `SESSION_DRIVER=database`)
y olvida sus tokens cacheados; vuelve a estar activa al entrar de nuevo cuando
Pireon la reactive. `token.revoked` cierra sus sesiones y olvida sus tokens
cacheados. La firma (`X-Webhook-Signature`, HMAC-SHA256 del cuerpo) vale con
cualquiera de los dos secrets; sin ninguno, el endpoint lo rechaza todo.
## Permisos
El catálogo vive en un único sitio: [`app/Support/Permissions.php`](app/Support/Permissions.php).