Add key expiry disable/enable toggle (#554)

This commit is contained in:
Julian Lehrhuber
2026-08-19 03:41:30 +02:00
committed by GitHub
parent 0feab692bd
commit cd59c310f6
9 changed files with 89 additions and 5 deletions
+6
View File
@@ -44,6 +44,11 @@ export interface Capabilities {
* the `hskey-authreq-` prefix. Introduced in 0.29.0.
*/
readonly registerKeyIncludesAuthReqPrefix: boolean;
/**
* Disabling of key expiry was introduced in 0.29.0.
*/
readonly keyExpiryCanBeDisabled: boolean;
}
export function capabilitiesFor(version: ServerVersion): Capabilities {
@@ -52,5 +57,6 @@ export function capabilitiesFor(version: ServerVersion): Capabilities {
nodeTagsAreFlat: gte(version, "0.28.0"),
nodeOwnerIsImmutable: gte(version, "0.28.0"),
registerKeyIncludesAuthReqPrefix: gte(version, "0.29.0"),
keyExpiryCanBeDisabled: gte(version, "0.29.0"),
};
}
@@ -19,6 +19,7 @@ export interface NodeApi {
expire(id: string): Promise<void>;
rename(id: string, newName: string): Promise<void>;
setTags(id: string, tags: string[]): Promise<void>;
toggleExpiry(nodeId: string, disableExpiry: boolean): Promise<void>;
/**
* Reassign a node to a different user. Only present when
* `capabilities.nodeOwnerIsImmutable` is false (Headscale < 0.28).
@@ -104,6 +105,13 @@ export function makeNodeApi(
body: { tags },
});
},
toggleExpiry: async (nodeId, disableExpiry) => {
await transport.request({
method: "POST",
path: `v1/node/${nodeId}/expire?disableExpiry=${disableExpiry}`,
apiKey,
});
},
};
if (!capabilities.nodeOwnerIsImmutable) {