mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 00:52:09 +00:00
Merge branch 'main' into feat/secretsBatchUI
This commit is contained in:
@@ -31,5 +31,6 @@ export enum AppConnection {
|
||||
Bitbucket = "bitbucket",
|
||||
Zabbix = "zabbix",
|
||||
Railway = "railway",
|
||||
Checkly = "checkly"
|
||||
Checkly = "checkly",
|
||||
Supabase = "supabase"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from "./queries";
|
||||
export * from "./types";
|
||||
@@ -0,0 +1,37 @@
|
||||
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
import { appConnectionKeys } from "@app/hooks/api/appConnections";
|
||||
|
||||
import { TSupabaseProject } from "./types";
|
||||
|
||||
const supabaseConnectionKeys = {
|
||||
all: [...appConnectionKeys.all, "supabase"] as const,
|
||||
listProjects: (connectionId: string) =>
|
||||
[...supabaseConnectionKeys.all, "workspace-scopes", connectionId] as const
|
||||
};
|
||||
|
||||
export const useSupabaseConnectionListProjects = (
|
||||
connectionId: string,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
TSupabaseProject[],
|
||||
unknown,
|
||||
TSupabaseProject[],
|
||||
ReturnType<typeof supabaseConnectionKeys.listProjects>
|
||||
>,
|
||||
"queryKey" | "queryFn"
|
||||
>
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: supabaseConnectionKeys.listProjects(connectionId),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{ projects: TSupabaseProject[] }>(
|
||||
`/api/v1/app-connections/supabase/${connectionId}/projects`
|
||||
);
|
||||
|
||||
return data.projects;
|
||||
},
|
||||
...options
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
export type TSupabaseProject = {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
@@ -148,6 +148,10 @@ export type TChecklyConnectionOption = TAppConnectionOptionBase & {
|
||||
app: AppConnection.Checkly;
|
||||
};
|
||||
|
||||
export type TSupabaseConnectionOption = TAppConnectionOptionBase & {
|
||||
app: AppConnection.Supabase;
|
||||
};
|
||||
|
||||
export type TAppConnectionOption =
|
||||
| TAwsConnectionOption
|
||||
| TGitHubConnectionOption
|
||||
@@ -215,4 +219,5 @@ export type TAppConnectionOptionMap = {
|
||||
[AppConnection.Zabbix]: TZabbixConnectionOption;
|
||||
[AppConnection.Railway]: TRailwayConnectionOption;
|
||||
[AppConnection.Checkly]: TChecklyConnectionOption;
|
||||
[AppConnection.Supabase]: TSupabaseConnectionOption;
|
||||
};
|
||||
|
||||
@@ -28,6 +28,7 @@ import { TOracleDBConnection } from "./oracledb-connection";
|
||||
import { TPostgresConnection } from "./postgres-connection";
|
||||
import { TRailwayConnection } from "./railway-connection";
|
||||
import { TRenderConnection } from "./render-connection";
|
||||
import { TSupabaseConnection } from "./supabase-connection";
|
||||
import { TTeamCityConnection } from "./teamcity-connection";
|
||||
import { TTerraformCloudConnection } from "./terraform-cloud-connection";
|
||||
import { TVercelConnection } from "./vercel-connection";
|
||||
@@ -99,7 +100,8 @@ export type TAppConnection =
|
||||
| TBitbucketConnection
|
||||
| TZabbixConnection
|
||||
| TRailwayConnection
|
||||
| TChecklyConnection;
|
||||
| TChecklyConnection
|
||||
| TSupabaseConnection;
|
||||
|
||||
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id">;
|
||||
|
||||
@@ -160,4 +162,5 @@ export type TAppConnectionMap = {
|
||||
[AppConnection.Zabbix]: TZabbixConnection;
|
||||
[AppConnection.Railway]: TRailwayConnection;
|
||||
[AppConnection.Checkly]: TChecklyConnection;
|
||||
[AppConnection.Supabase]: TSupabaseConnection;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
|
||||
|
||||
export enum SupabaseConnectionMethod {
|
||||
AccessToken = "access-token"
|
||||
}
|
||||
|
||||
export type TSupabaseConnection = TRootAppConnection & {
|
||||
app: AppConnection.Supabase;
|
||||
method: SupabaseConnectionMethod.AccessToken;
|
||||
credentials: {
|
||||
instanceUrl?: string;
|
||||
accessKey: string;
|
||||
};
|
||||
};
|
||||
@@ -22,7 +22,7 @@ export enum SecretSync {
|
||||
GitLab = "gitlab",
|
||||
CloudflarePages = "cloudflare-pages",
|
||||
CloudflareWorkers = "cloudflare-workers",
|
||||
|
||||
Supabase = "supabase",
|
||||
Zabbix = "zabbix",
|
||||
Railway = "railway",
|
||||
Checkly = "checkly"
|
||||
|
||||
@@ -22,6 +22,7 @@ import { THerokuSync } from "./heroku-sync";
|
||||
import { THumanitecSync } from "./humanitec-sync";
|
||||
import { TOCIVaultSync } from "./oci-vault-sync";
|
||||
import { TRailwaySync } from "./railway-sync";
|
||||
import { TSupabaseSync } from "./supabase";
|
||||
import { TTeamCitySync } from "./teamcity-sync";
|
||||
import { TTerraformCloudSync } from "./terraform-cloud-sync";
|
||||
import { TVercelSync } from "./vercel-sync";
|
||||
@@ -61,7 +62,8 @@ export type TSecretSync =
|
||||
| TCloudflareWorkersSync
|
||||
| TZabbixSync
|
||||
| TRailwaySync
|
||||
| TChecklySync;
|
||||
| TChecklySync
|
||||
| TSupabaseSync;
|
||||
|
||||
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||
import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
|
||||
|
||||
export type TSupabaseSync = TRootSecretSync & {
|
||||
destination: SecretSync.Supabase;
|
||||
destinationConfig: {
|
||||
projectId: string;
|
||||
projectName: string;
|
||||
};
|
||||
connection: {
|
||||
app: AppConnection.Supabase;
|
||||
name: string;
|
||||
id: string;
|
||||
};
|
||||
};
|
||||
@@ -17,8 +17,8 @@ export type SubscriptionPlan = {
|
||||
rbac: boolean;
|
||||
secretVersioning: boolean;
|
||||
slug: string;
|
||||
secretApproval: string;
|
||||
secretRotation: string;
|
||||
secretApproval: boolean;
|
||||
secretRotation: boolean;
|
||||
tier: number;
|
||||
workspaceLimit: number;
|
||||
workspacesUsed: number;
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { useSubscription, useWorkspace } from "@app/context";
|
||||
import { useGetAccessApprovalPolicies } from "@app/hooks/api";
|
||||
|
||||
const matchesPath = (folderPath: string, pattern: string) => {
|
||||
const normalizedPath = folderPath === "/" ? "/" : folderPath.replace(/\/$/, "");
|
||||
const normalizedPattern = pattern === "/" ? "/" : pattern.replace(/\/$/, "");
|
||||
|
||||
if (normalizedPath === normalizedPattern) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (normalizedPattern.endsWith("/**")) {
|
||||
const basePattern = normalizedPattern.slice(0, -3); // Remove "/**"
|
||||
|
||||
// Handle root wildcard "/**"
|
||||
if (basePattern === "") {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if path starts with the base pattern
|
||||
if (normalizedPath === basePattern) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if path is a subdirectory of the base pattern
|
||||
return normalizedPath.startsWith(`${basePattern}/`);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
type Params = {
|
||||
secretPath: string;
|
||||
environment: string;
|
||||
};
|
||||
|
||||
export const usePathAccessPolicies = ({ secretPath, environment }: Params) => {
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { subscription } = useSubscription();
|
||||
const { data: policies } = useGetAccessApprovalPolicies({
|
||||
projectSlug: currentWorkspace.slug,
|
||||
options: {
|
||||
enabled: subscription.secretApproval
|
||||
}
|
||||
});
|
||||
|
||||
return useMemo(() => {
|
||||
const pathPolicies = policies?.filter(
|
||||
(policy) =>
|
||||
policy.environment.slug === environment && matchesPath(secretPath, policy.secretPath)
|
||||
);
|
||||
|
||||
return {
|
||||
hasPathPolicies: subscription.secretApproval && Boolean(pathPolicies?.length),
|
||||
pathPolicies
|
||||
};
|
||||
}, [secretPath, environment, policies, subscription.secretApproval]);
|
||||
};
|
||||
Reference in New Issue
Block a user