mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 11:38:55 +00:00
Merge remote-tracking branch 'origin' into daniel/permission-visualization
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
SRP1DTO,
|
||||
SRPR1Res,
|
||||
TOauthTokenExchangeDTO,
|
||||
UserAgentType,
|
||||
VerifyMfaTokenDTO,
|
||||
VerifyMfaTokenRes,
|
||||
VerifySignupInviteDTO
|
||||
@@ -60,7 +61,10 @@ export const useLogin1 = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const selectOrganization = async (data: { organizationId: string }) => {
|
||||
export const selectOrganization = async (data: {
|
||||
organizationId: string;
|
||||
userAgent?: UserAgentType;
|
||||
}) => {
|
||||
const { data: res } = await apiRequest.post<{ token: string }>(
|
||||
"/api/v3/auth/select-organization",
|
||||
data
|
||||
@@ -71,11 +75,14 @@ export const selectOrganization = async (data: { organizationId: string }) => {
|
||||
export const useSelectOrganization = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async (details: { organizationId: string }) => {
|
||||
mutationFn: async (details: { organizationId: string; userAgent?: UserAgentType }) => {
|
||||
const data = await selectOrganization(details);
|
||||
|
||||
SecurityClient.setToken(data.token);
|
||||
SecurityClient.setProviderAuthToken("");
|
||||
// If a custom user agent is set, then this session is meant for another consuming application, not the web application.
|
||||
if (!details.userAgent) {
|
||||
SecurityClient.setToken(data.token);
|
||||
SecurityClient.setProviderAuthToken("");
|
||||
}
|
||||
|
||||
return data;
|
||||
},
|
||||
|
||||
@@ -145,3 +145,7 @@ export type IssueBackupPrivateKeyDTO = {
|
||||
export type GetBackupEncryptedPrivateKeyDTO = {
|
||||
verificationToken: string;
|
||||
};
|
||||
|
||||
export enum UserAgentType {
|
||||
CLI = "cli"
|
||||
}
|
||||
|
||||
@@ -8,4 +8,4 @@ export {
|
||||
useSignIntermediate,
|
||||
useUpdateCa
|
||||
} from "./mutations";
|
||||
export { useGetCaById, useGetCaCert, useGetCaCerts, useGetCaCrls, useGetCaCsr } from "./queries";
|
||||
export { useGetCaById, useGetCaCert, useGetCaCerts, useGetCaCertTemplates,useGetCaCrls, useGetCaCsr } from "./queries";
|
||||
|
||||
@@ -43,8 +43,9 @@ export const useUpdateCa = () => {
|
||||
} = await apiRequest.patch<{ ca: TCertificateAuthority }>(`/api/v1/pki/ca/${caId}`, body);
|
||||
return ca;
|
||||
},
|
||||
onSuccess: (_, { projectSlug }) => {
|
||||
onSuccess: ({ id }, { projectSlug }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCas({ projectSlug }));
|
||||
queryClient.invalidateQueries(caKeys.getCaById(id));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { TCertificateTemplate } from "../certificateTemplates/types";
|
||||
import { TCertificateAuthority } from "./types";
|
||||
|
||||
export const caKeys = {
|
||||
@@ -11,6 +12,7 @@ export const caKeys = {
|
||||
getCaCert: (caId: string) => [{ caId }, "ca-cert"],
|
||||
getCaCsr: (caId: string) => [{ caId }, "ca-csr"],
|
||||
getCaCrl: (caId: string) => [{ caId }, "ca-crl"],
|
||||
getCaCertTemplates: (caId: string) => [{ caId }, "ca-cert-templates"],
|
||||
getCaEstConfig: (caId: string) => [{ caId }, "ca-est-config"]
|
||||
};
|
||||
|
||||
@@ -90,3 +92,16 @@ export const useGetCaCrls = (caId: string) => {
|
||||
enabled: Boolean(caId)
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetCaCertTemplates = (caId: string) => {
|
||||
return useQuery({
|
||||
queryKey: caKeys.getCaCertTemplates(caId),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{
|
||||
certificateTemplates: TCertificateTemplate[];
|
||||
}>(`/api/v1/pki/ca/${caId}/certificate-templates`);
|
||||
return data;
|
||||
},
|
||||
enabled: Boolean(caId)
|
||||
});
|
||||
};
|
||||
@@ -19,6 +19,7 @@ export type TCertificateAuthority = {
|
||||
notAfter?: string;
|
||||
notBefore?: string;
|
||||
keyAlgorithm: CertKeyAlgorithm;
|
||||
requireTemplateForIssuance: boolean;
|
||||
activeCaCertId?: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@@ -37,12 +38,14 @@ export type TCreateCaDTO = {
|
||||
notAfter?: string;
|
||||
maxPathLength: number;
|
||||
keyAlgorithm: CertKeyAlgorithm;
|
||||
requireTemplateForIssuance: boolean;
|
||||
};
|
||||
|
||||
export type TUpdateCaDTO = {
|
||||
projectSlug: string;
|
||||
caId: string;
|
||||
status?: CaStatus;
|
||||
requireTemplateForIssuance?: boolean;
|
||||
};
|
||||
|
||||
export type TDeleteCaDTO = {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { caKeys } from "../ca/queries";
|
||||
import { workspaceKeys } from "../workspace/queries";
|
||||
import { certTemplateKeys } from "./queries";
|
||||
import {
|
||||
@@ -23,8 +24,9 @@ export const useCreateCertTemplate = () => {
|
||||
);
|
||||
return certificateTemplate;
|
||||
},
|
||||
onSuccess: (_, { projectId }) => {
|
||||
onSuccess: ({ caId }, { projectId }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCertificateTemplates(projectId));
|
||||
queryClient.invalidateQueries(caKeys.getCaCertTemplates(caId));
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -40,22 +42,25 @@ export const useUpdateCertTemplate = () => {
|
||||
|
||||
return certificateTemplate;
|
||||
},
|
||||
onSuccess: (_, { projectId, id }) => {
|
||||
onSuccess: ({ caId }, { projectId, id }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCertificateTemplates(projectId));
|
||||
queryClient.invalidateQueries(certTemplateKeys.getCertTemplateById(id));
|
||||
queryClient.invalidateQueries(caKeys.getCaCertTemplates(caId));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useDeleteCertTemplate = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation<void, {}, TDeleteCertificateTemplateDTO>({
|
||||
return useMutation<TCertificateTemplate, {}, TDeleteCertificateTemplateDTO>({
|
||||
mutationFn: async (data) => {
|
||||
return apiRequest.delete(`/api/v1/pki/certificate-templates/${data.id}`);
|
||||
const { data: certificateTemplate } = await apiRequest.delete<TCertificateTemplate>(`/api/v1/pki/certificate-templates/${data.id}`);
|
||||
return certificateTemplate;
|
||||
},
|
||||
onSuccess: (_, { projectId, id }) => {
|
||||
onSuccess: ({ caId }, { projectId, id }) => {
|
||||
queryClient.invalidateQueries(workspaceKeys.getWorkspaceCertificateTemplates(projectId));
|
||||
queryClient.invalidateQueries(certTemplateKeys.getCertTemplateById(id));
|
||||
queryClient.invalidateQueries(caKeys.getCaCertTemplates(caId));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -22,7 +22,9 @@ export enum DynamicSecretProviders {
|
||||
Redis = "redis",
|
||||
AwsElastiCache = "aws-elasticache",
|
||||
MongoAtlas = "mongo-db-atlas",
|
||||
ElasticSearch = "elastic-search"
|
||||
ElasticSearch = "elastic-search",
|
||||
MongoDB = "mongo-db",
|
||||
RabbitMq = "rabbit-mq"
|
||||
}
|
||||
|
||||
export enum SqlProviders {
|
||||
@@ -117,6 +119,24 @@ export type TDynamicSecretProvider =
|
||||
}[];
|
||||
};
|
||||
}
|
||||
| {
|
||||
type: DynamicSecretProviders.MongoDB;
|
||||
inputs: {
|
||||
host: string;
|
||||
port?: number;
|
||||
database: string;
|
||||
username: string;
|
||||
password: string;
|
||||
ca?: string | undefined;
|
||||
roles: (
|
||||
| {
|
||||
databaseName: string;
|
||||
roleName: string;
|
||||
}
|
||||
| string
|
||||
)[];
|
||||
};
|
||||
}
|
||||
| {
|
||||
type: DynamicSecretProviders.ElasticSearch;
|
||||
inputs: {
|
||||
@@ -124,7 +144,6 @@ export type TDynamicSecretProvider =
|
||||
port: number;
|
||||
ca?: string | undefined;
|
||||
roles: string[];
|
||||
|
||||
auth:
|
||||
| {
|
||||
type: "user";
|
||||
@@ -137,6 +156,27 @@ export type TDynamicSecretProvider =
|
||||
apiKeyId: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
| {
|
||||
type: DynamicSecretProviders.RabbitMq;
|
||||
inputs: {
|
||||
host: string;
|
||||
port: number;
|
||||
|
||||
username: string;
|
||||
password: string;
|
||||
|
||||
tags: string[];
|
||||
virtualHost: {
|
||||
name: string;
|
||||
permissions: {
|
||||
configure: string;
|
||||
write: string;
|
||||
read: string;
|
||||
};
|
||||
};
|
||||
ca?: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type TCreateDynamicSecretDTO = {
|
||||
|
||||
Reference in New Issue
Block a user