Add sign SSH key operation to frontend

This commit is contained in:
Tuan Dang
2024-12-04 20:13:30 -08:00
parent a5a1f57284
commit 5b618b07fa
5 changed files with 152 additions and 53 deletions
+6 -1
View File
@@ -1,3 +1,8 @@
export { SshCaStatus } from "./enums";
export { useCreateSshCa, useDeleteSshCa, useIssueSshCreds,useUpdateSshCa } from "./mutations";
export {
useCreateSshCa,
useDeleteSshCa,
useIssueSshCreds,
useSignSshKey,
useUpdateSshCa} from "./mutations";
export { useGetSshCaById, useGetSshCaCertTemplates } from "./queries";
@@ -8,6 +8,8 @@ import {
TDeleteSshCaDTO,
TIssueSshCredsDTO,
TIssueSshCredsResponse,
TSignSshKeyDTO,
TSignSshKeyResponse,
TSshCertificateAuthority,
TUpdateSshCaDTO} from "./types";
@@ -61,6 +63,15 @@ export const useDeleteSshCa = () => {
});
};
export const useSignSshKey = () => {
return useMutation<TSignSshKeyResponse, {}, TSignSshKeyDTO>({
mutationFn: async (body) => {
const { data } = await apiRequest.post<TSignSshKeyResponse>("/api/v1/ssh/sign", body);
return data;
}
});
};
export const useIssueSshCreds = () => {
return useMutation<TIssueSshCredsResponse, {}, TIssueSshCredsDTO>({
mutationFn: async (body) => {
+14
View File
@@ -27,6 +27,20 @@ export type TDeleteSshCaDTO = {
caId: string;
};
export type TSignSshKeyDTO = {
templateName: string;
publicKey?: string;
certType: SshCertType;
principals: string[];
ttl?: string;
keyId?: string;
};
export type TSignSshKeyResponse = {
serialNumber: string;
signedKey: string;
};
export type TIssueSshCredsDTO = {
templateName: string;
keyAlgorithm: CertKeyAlgorithm;