db, api/v1: revoke rather than delete an ephemeral pre-auth key in use

The v1 list now hides revoked keys, so keys revoked through v2 also drop
out of `headscale preauthkeys list`.
This commit is contained in:
Kristoffer Dalby committed 2026-10-28 16:35:22 +00:00
1 parent 044b6b61fb
commit f26853dc7f
5 files changed
+114 -5

No files matched your search

+7 -2
View File
@@ -202,9 +202,14 @@ func registerPreAuthKeys(api huma.API, b Backend) {
out := &listPreAuthKeysOutput{}
out.Body.PreAuthKeys = make([]PreAuthKey, len(preAuthKeys))
out.Body.PreAuthKeys = make([]PreAuthKey, 0, len(preAuthKeys))
for i := range preAuthKeys {
out.Body.PreAuthKeys[i] = preAuthKeyToResponse(&preAuthKeys[i])
if preAuthKeys[i].Revoked == nil {
out.Body.PreAuthKeys = append(
out.Body.PreAuthKeys,
preAuthKeyToResponse(&preAuthKeys[i]),
)
}
}
return out, nil