Fix merge conflicts

This commit is contained in:
Tuan Dang
2024-06-25 14:46:58 -07:00
171 changed files with 4384 additions and 535 deletions
+3
View File
@@ -5,7 +5,10 @@ export type TServerConfig = {
isMigrationModeOn?: boolean;
trustSamlEmails: boolean;
trustLdapEmails: boolean;
trustOidcEmails: boolean;
isSecretScanningDisabled: boolean;
defaultAuthOrgSlug: string | null;
defaultAuthOrgId: string | null;
};
export type TCreateAdminUserDTO = {
+1
View File
@@ -81,6 +81,7 @@ export type TCreateCertificateDTO = {
caId: string;
friendlyName?: string;
commonName: string;
altNames: string; // sans
ttl: string; // string compatible with ms
notBefore?: string;
notAfter?: string;
@@ -6,6 +6,7 @@ export type TCertificate = {
status: CertStatus;
friendlyName: string;
commonName: string;
altNames: string;
serialNumber: string;
notBefore: string;
notAfter: string;
+1
View File
@@ -17,6 +17,7 @@ export * from "./integrationAuth";
export * from "./integrations";
export * from "./keys";
export * from "./ldapConfig";
export * from "./oidcConfig";
export * from "./organization";
export * from "./projectUserAdditionalPrivilege";
export * from "./rateLimit";
@@ -0,0 +1 @@
export * from "./queries";
@@ -0,0 +1,111 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { oidcConfigKeys } from "./queries";
export const useUpdateOIDCConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async ({
issuer,
authorizationEndpoint,
configurationType,
discoveryURL,
jwksUri,
tokenEndpoint,
userinfoEndpoint,
allowedEmailDomains,
clientId,
clientSecret,
isActive,
orgSlug
}: {
allowedEmailDomains?: string;
issuer?: string;
authorizationEndpoint?: string;
discoveryURL?: string;
jwksUri?: string;
tokenEndpoint?: string;
userinfoEndpoint?: string;
clientId?: string;
clientSecret?: string;
isActive?: boolean;
configurationType?: string;
orgSlug: string;
}) => {
const { data } = await apiRequest.patch("/api/v1/sso/oidc/config", {
issuer,
allowedEmailDomains,
authorizationEndpoint,
discoveryURL,
configurationType,
jwksUri,
tokenEndpoint,
userinfoEndpoint,
clientId,
orgSlug,
clientSecret,
isActive
});
return data;
},
onSuccess(_, dto) {
queryClient.invalidateQueries(oidcConfigKeys.getOIDCConfig(dto.orgSlug));
}
});
};
export const useCreateOIDCConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async ({
issuer,
configurationType,
discoveryURL,
authorizationEndpoint,
allowedEmailDomains,
jwksUri,
tokenEndpoint,
userinfoEndpoint,
clientId,
clientSecret,
isActive,
orgSlug
}: {
issuer?: string;
configurationType: string;
discoveryURL?: string;
authorizationEndpoint?: string;
jwksUri?: string;
tokenEndpoint?: string;
userinfoEndpoint?: string;
clientId: string;
clientSecret: string;
isActive: boolean;
orgSlug: string;
allowedEmailDomains?: string;
}) => {
const { data } = await apiRequest.post("/api/v1/sso/oidc/config", {
issuer,
configurationType,
discoveryURL,
authorizationEndpoint,
allowedEmailDomains,
jwksUri,
tokenEndpoint,
userinfoEndpoint,
clientId,
clientSecret,
isActive,
orgSlug
});
return data;
},
onSuccess(_, dto) {
queryClient.invalidateQueries(oidcConfigKeys.getOIDCConfig(dto.orgSlug));
}
});
};
@@ -0,0 +1,23 @@
import { useQuery } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { OIDCConfigData } from "./types";
export const oidcConfigKeys = {
getOIDCConfig: (orgSlug: string) => [{ orgSlug }, "organization-oidc"] as const
};
export const useGetOIDCConfig = (orgSlug: string) => {
return useQuery({
queryKey: oidcConfigKeys.getOIDCConfig(orgSlug),
queryFn: async () => {
const { data } = await apiRequest.get<OIDCConfigData>(
`/api/v1/sso/oidc/config?orgSlug=${orgSlug}`
);
return data;
},
enabled: true
});
};
@@ -0,0 +1,15 @@
export type OIDCConfigData = {
id: string;
issuer: string;
authorizationEndpoint: string;
configurationType: string;
discoveryURL: string;
jwksUri: string;
tokenEndpoint: string;
userinfoEndpoint: string;
isActive: boolean;
orgId: string;
clientId: string;
clientSecret: string;
allowedEmailDomains?: string;
};
@@ -279,7 +279,28 @@ export const useGetImportedSecretsAllEnvs = ({
[(secretImports || []).map((response) => response.data)]
);
return { secretImports, isImportedSecretPresentInEnv };
const getImportedSecretByKey = useCallback(
(envSlug: string, secretName: string) => {
const selectedEnvIndex = environments.indexOf(envSlug);
if (selectedEnvIndex !== -1) {
const secret = secretImports?.[selectedEnvIndex]?.data?.find(({ secrets }) =>
secrets.find((s) => s.key === secretName)
);
if (!secret) return undefined;
return {
secret: secret?.secrets.find((s) => s.key === secretName),
environmentInfo: secret?.environmentInfo
};
}
return undefined;
},
[(secretImports || []).map((response) => response.data)]
);
return { secretImports, isImportedSecretPresentInEnv, getImportedSecretByKey };
};
export const useGetImportedFoldersByEnv = ({
@@ -7,7 +7,7 @@ import {
} from "@app/components/utilities/cryptography/crypto";
import { apiRequest } from "@app/config/request";
import { DecryptedSecret } from "../secrets/types";
import { DecryptedSecret, SecretType } from "../secrets/types";
import {
TGetSecretSnapshotsDTO,
TSecretRollbackDTO,
@@ -112,7 +112,7 @@ export const useGetSnapshotSecrets = ({ decryptFileKey, snapshotId }: TSnapshotD
version: encSecret.version
};
if (encSecret.type === "personal") {
if (encSecret.type === SecretType.Personal) {
personalSecrets[decryptedSecret.key] = { id: encSecret.secretId, value: secretValue };
} else {
sharedSecrets.push(decryptedSecret);
+2 -1
View File
@@ -14,6 +14,7 @@ import {
EncryptedSecret,
EncryptedSecretVersion,
GetSecretVersionsDTO,
SecretType,
TGetProjectSecretsAllEnvDTO,
TGetProjectSecretsDTO,
TGetProjectSecretsKey
@@ -77,7 +78,7 @@ export const decryptSecrets = (
skipMultilineEncoding: encSecret.skipMultilineEncoding
};
if (encSecret.type === "personal") {
if (encSecret.type === SecretType.Personal) {
personalSecrets[decryptedSecret.key] = {
id: encSecret.id,
value: secretValue
+14 -9
View File
@@ -1,11 +1,16 @@
import type { UserWsKeyPair } from "../keys/types";
import type { WsTag } from "../tags/types";
export enum SecretType {
Shared = "shared",
Personal = "personal"
}
export type EncryptedSecret = {
id: string;
version: number;
workspace: string;
type: "shared" | "personal";
type: SecretType;
environment: string;
secretKeyCiphertext: string;
secretKeyIV: string;
@@ -49,7 +54,7 @@ export type EncryptedSecretVersion = {
secretId: string;
version: number;
workspace: string;
type: string;
type: SecretType;
isDeleted: boolean;
envId: string;
secretKeyCiphertext: string;
@@ -101,14 +106,14 @@ export type TCreateSecretsV3DTO = {
secretPath: string;
workspaceId: string;
environment: string;
type: string;
type: SecretType;
};
export type TUpdateSecretsV3DTO = {
latestFileKey: UserWsKeyPair;
workspaceId: string;
environment: string;
type: string;
type: SecretType;
secretPath: string;
skipMultilineEncoding?: boolean;
newSecretName?: string;
@@ -124,7 +129,7 @@ export type TUpdateSecretsV3DTO = {
export type TDeleteSecretsV3DTO = {
workspaceId: string;
environment: string;
type: "shared" | "personal";
type: SecretType;
secretPath: string;
secretName: string;
secretId?: string;
@@ -140,7 +145,7 @@ export type TCreateSecretBatchDTO = {
secretValue: string;
secretComment: string;
skipMultilineEncoding?: boolean;
type: "shared" | "personal";
type: SecretType;
metadata?: {
source?: string;
};
@@ -153,7 +158,7 @@ export type TUpdateSecretBatchDTO = {
secretPath: string;
latestFileKey: UserWsKeyPair;
secrets: Array<{
type: "shared" | "personal";
type: SecretType;
secretName: string;
skipMultilineEncoding?: boolean;
secretValue: string;
@@ -168,14 +173,14 @@ export type TDeleteSecretBatchDTO = {
secretPath: string;
secrets: Array<{
secretName: string;
type: "shared" | "personal";
type: SecretType;
}>;
};
export type CreateSecretDTO = {
workspaceId: string;
environment: string;
type: "shared" | "personal";
type: SecretType;
secretKey: string;
secretKeyCiphertext: string;
secretKeyIV: string;
@@ -4,5 +4,5 @@ export type ServerStatus = {
emailConfigured: boolean;
secretScanningConfigured: boolean;
redisConfigured: boolean;
samlDefaultOrgSlug: boolean
samlDefaultOrgSlug: string;
};
@@ -23,6 +23,7 @@ export type SubscriptionPlan = {
workspacesUsed: number;
environmentLimit: number;
samlSSO: boolean;
oidcSSO: boolean;
scim: boolean;
ldap: boolean;
groups: boolean;
+2 -1
View File
@@ -29,7 +29,8 @@ export type User = {
export enum UserAliasType {
LDAP = "ldap",
SAML = "saml"
SAML = "saml",
OIDC = "oidc"
}
export type UserEnc = {