Add issue SSH certificate modal

This commit is contained in:
Tuan Dang
2024-12-03 18:36:32 -08:00
parent 07d9398aad
commit 3b2173a098
10 changed files with 513 additions and 15 deletions
+5
View File
@@ -2,3 +2,8 @@ export enum SshCaStatus {
ACTIVE = "active",
DISABLED = "disabled"
}
export enum SshCertType {
USER = "user",
HOST = "host"
}
+1 -1
View File
@@ -1,3 +1,3 @@
export { SshCaStatus } from "./enums";
export { useCreateSshCa, useDeleteSshCa,useUpdateSshCa } from "./mutations";
export { useCreateSshCa, useDeleteSshCa, useIssueSshCreds,useUpdateSshCa } from "./mutations";
export { useGetSshCaById, useGetSshCaCertTemplates } from "./queries";
+11 -1
View File
@@ -1,4 +1,3 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
@@ -7,6 +6,8 @@ import { organizationKeys } from "../organization/queries";
import {
TCreateSshCaDTO,
TDeleteSshCaDTO,
TIssueSshCredsDTO,
TIssueSshCredsResponse,
TSshCertificateAuthority,
TUpdateSshCaDTO} from "./types";
@@ -59,3 +60,12 @@ export const useDeleteSshCa = () => {
}
});
};
export const useIssueSshCreds = () => {
return useMutation<TIssueSshCredsResponse, {}, TIssueSshCredsDTO>({
mutationFn: async (body) => {
const { data } = await apiRequest.post<TIssueSshCredsResponse>("/api/v1/ssh/issue", body);
return data;
}
});
};
+18 -1
View File
@@ -1,5 +1,5 @@
import { CertKeyAlgorithm } from "../certificates/enums";
import { SshCaStatus } from "./enums";
import { SshCaStatus, SshCertType } from "./enums";
export type TSshCertificateAuthority = {
id: string;
@@ -26,3 +26,20 @@ export type TUpdateSshCaDTO = {
export type TDeleteSshCaDTO = {
caId: string;
};
export type TIssueSshCredsDTO = {
templateName: string;
keyAlgorithm: CertKeyAlgorithm;
certType: SshCertType;
principals: string[];
ttl?: string;
keyId?: string;
};
export type TIssueSshCredsResponse = {
serialNumber: string;
signedKey: string;
privateKey: string;
publicKey: string;
keyAlgorithm: CertKeyAlgorithm;
};