mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 10:35:17 +00:00
Add SSH certificate tab + data structure
This commit is contained in:
@@ -20,5 +20,7 @@ export {
|
||||
useGetOrgTaxIds,
|
||||
useGetOrgTrialUrl,
|
||||
useListOrgSshCas,
|
||||
useListOrgSshCertificates,
|
||||
useListOrgSshCertificateTemplates,
|
||||
useUpdateOrg,
|
||||
useUpdateOrgBillingDetails} from "./queries";
|
||||
|
||||
@@ -4,7 +4,8 @@ import { apiRequest } from "@app/config/request";
|
||||
import { OrderByDirection } from "@app/hooks/api/generic/types";
|
||||
|
||||
import { TGroupOrgMembership } from "../groups/types";
|
||||
import { TSshCertificateAuthority } from "../ssh-ca/types";
|
||||
import { TSshCertificate,TSshCertificateAuthority } from "../ssh-ca/types";
|
||||
import { TSshCertificateTemplate } from "../sshCertificateTemplates/types";
|
||||
import { IntegrationAuth } from "../types";
|
||||
import {
|
||||
BillingDetails,
|
||||
@@ -43,7 +44,11 @@ export const organizationKeys = {
|
||||
[...organizationKeys.getOrgIdentityMemberships(orgId), params] as const,
|
||||
getOrgGroups: (orgId: string) => [{ orgId }, "organization-groups"] as const,
|
||||
getOrgIntegrationAuths: (orgId: string) => [{ orgId }, "integration-auths"] as const,
|
||||
getOrgSshCas: ({ orgId }: { orgId: string }) => [{ orgId }, "org-ssh-cas"] as const
|
||||
getOrgSshCas: ({ orgId }: { orgId: string }) => [{ orgId }, "org-ssh-cas"] as const,
|
||||
allOrgSshCertificates: () => ["org-ssh-certificates"] as const,
|
||||
specificOrgSshCertificates: ({ offset, limit }: { offset: number; limit: number }) =>
|
||||
[...organizationKeys.allOrgSshCertificates(), { offset, limit }] as const,
|
||||
getOrgSshCertificateTemplates: () => ["org-ssh-certificate-templates"] as const
|
||||
};
|
||||
|
||||
export const fetchOrganizations = async () => {
|
||||
@@ -512,3 +517,48 @@ export const useListOrgSshCas = ({ orgId }: { orgId: string }) => {
|
||||
enabled: Boolean(orgId)
|
||||
});
|
||||
};
|
||||
|
||||
export const useListOrgSshCertificates = ({
|
||||
orgId,
|
||||
offset,
|
||||
limit
|
||||
}: {
|
||||
orgId: string;
|
||||
offset: number;
|
||||
limit: number;
|
||||
}) => {
|
||||
return useQuery({
|
||||
queryKey: organizationKeys.specificOrgSshCertificates({
|
||||
offset,
|
||||
limit
|
||||
}),
|
||||
queryFn: async () => {
|
||||
const params = new URLSearchParams({
|
||||
offset: String(offset),
|
||||
limit: String(limit)
|
||||
});
|
||||
|
||||
const { data } = await apiRequest.get<{
|
||||
certificates: TSshCertificate[];
|
||||
totalCount: number;
|
||||
}>(`/api/v1/organization/${orgId}/ssh-certificates`, {
|
||||
params
|
||||
});
|
||||
return data;
|
||||
},
|
||||
enabled: Boolean(orgId)
|
||||
});
|
||||
};
|
||||
|
||||
export const useListOrgSshCertificateTemplates = ({ orgId }: { orgId: string }) => {
|
||||
return useQuery({
|
||||
queryKey: organizationKeys.getOrgSshCertificateTemplates(),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{ certificateTemplates: TSshCertificateTemplate[] }>(
|
||||
`/api/v1/organization/${orgId}/ssh-certificate-templates`
|
||||
);
|
||||
return data;
|
||||
},
|
||||
enabled: Boolean(orgId)
|
||||
});
|
||||
};
|
||||
|
||||
@@ -7,3 +7,8 @@ export enum SshCertType {
|
||||
USER = "user",
|
||||
HOST = "host"
|
||||
}
|
||||
|
||||
export const sshCertTypeToNameMap: { [K in SshCertType]: string } = {
|
||||
[SshCertType.USER]: "User",
|
||||
[SshCertType.HOST]: "Host"
|
||||
};
|
||||
@@ -1,8 +1,9 @@
|
||||
export { SshCaStatus } from "./enums";
|
||||
export { SshCaStatus } from "./constants";
|
||||
export {
|
||||
useCreateSshCa,
|
||||
useDeleteSshCa,
|
||||
useIssueSshCreds,
|
||||
useSignSshKey,
|
||||
useUpdateSshCa} from "./mutations";
|
||||
useUpdateSshCa
|
||||
} from "./mutations";
|
||||
export { useGetSshCaById, useGetSshCaCertTemplates } from "./queries";
|
||||
|
||||
@@ -11,7 +11,8 @@ import {
|
||||
TSignSshKeyDTO,
|
||||
TSignSshKeyResponse,
|
||||
TSshCertificateAuthority,
|
||||
TUpdateSshCaDTO} from "./types";
|
||||
TUpdateSshCaDTO
|
||||
} from "./types";
|
||||
|
||||
export const sshCaKeys = {
|
||||
getSshCaById: (caId: string) => [{ caId }, "ssh-ca"]
|
||||
@@ -64,19 +65,27 @@ export const useDeleteSshCa = () => {
|
||||
};
|
||||
|
||||
export const useSignSshKey = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TSignSshKeyResponse, {}, TSignSshKeyDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post<TSignSshKeyResponse>("/api/v1/ssh/sign", body);
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(organizationKeys.allOrgSshCertificates());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useIssueSshCreds = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<TIssueSshCredsResponse, {}, TIssueSshCredsDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post<TIssueSshCredsResponse>("/api/v1/ssh/issue", body);
|
||||
return data;
|
||||
},
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(organizationKeys.allOrgSshCertificates());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import { CertKeyAlgorithm } from "../certificates/enums";
|
||||
import { SshCaStatus, SshCertType } from "./enums";
|
||||
import { SshCaStatus, SshCertType } from "./constants";
|
||||
|
||||
export type TSshCertificate = {
|
||||
id: string;
|
||||
sshCaId: string;
|
||||
sshCertificateTemplateId: string;
|
||||
serialNumber: string;
|
||||
certType: SshCertType;
|
||||
publicKey: string;
|
||||
principals: string[];
|
||||
keyId: string;
|
||||
};
|
||||
|
||||
export type TSshCertificateAuthority = {
|
||||
id: string;
|
||||
|
||||
Reference in New Issue
Block a user