mirror of
https://github.com/tale/headplane.git
synced 2026-08-18 17:06:17 +00:00
list all preauth keys without user filter
headscale 0.28 added GET /v1/preauthkey without a user param which returns all keys including tag-only ones. this change adds getAllPreAuthKeys() and uses it when available, falling back to per-user fetching on older versions. the UI now handles keys where user is null, showing them as Tag Only in the filter dropdown. closes #432 Amp-Thread-ID: https://ampcode.com/threads/T-019c9861-2d45-73ef-ab94-5fce62f63670 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -3,6 +3,11 @@ import type { PreAuthKey } from "~/types";
|
||||
import { defineApiEndpoints } from "../factory";
|
||||
|
||||
export interface PreAuthKeyEndpoints {
|
||||
/**
|
||||
* List all pre-auth keys. Requires Headscale 0.28+.
|
||||
*/
|
||||
getAllPreAuthKeys(): Promise<PreAuthKey[]>;
|
||||
|
||||
/**
|
||||
* Retrieves all pre-authentication keys for a specific user.
|
||||
*
|
||||
@@ -33,6 +38,14 @@ export interface PreAuthKeyEndpoints {
|
||||
}
|
||||
|
||||
export default defineApiEndpoints<PreAuthKeyEndpoints>((client, apiKey) => ({
|
||||
getAllPreAuthKeys: async () => {
|
||||
const { preAuthKeys } = await client.apiFetch<{
|
||||
preAuthKeys: PreAuthKey[];
|
||||
}>("GET", "v1/preauthkey", apiKey, {});
|
||||
|
||||
return preAuthKeys;
|
||||
},
|
||||
|
||||
getPreAuthKeys: async (user) => {
|
||||
const { preAuthKeys } = await client.apiFetch<{
|
||||
preAuthKeys: PreAuthKey[];
|
||||
|
||||
Reference in New Issue
Block a user