Merge remote-tracking branch 'origin/main' into feat/add-cloudflare-app-connection-and-sync
@@ -50,6 +50,8 @@ export const initDbConnection = ({
|
|||||||
}
|
}
|
||||||
: false
|
: false
|
||||||
},
|
},
|
||||||
|
// https://knexjs.org/guide/#pool
|
||||||
|
pool: { min: 0, max: 10 },
|
||||||
migrations: {
|
migrations: {
|
||||||
tableName: "infisical_migrations"
|
tableName: "infisical_migrations"
|
||||||
}
|
}
|
||||||
@@ -70,7 +72,8 @@ export const initDbConnection = ({
|
|||||||
},
|
},
|
||||||
migrations: {
|
migrations: {
|
||||||
tableName: "infisical_migrations"
|
tableName: "infisical_migrations"
|
||||||
}
|
},
|
||||||
|
pool: { min: 0, max: 10 }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -128,11 +128,21 @@ export const AwsIamProvider = (): TDynamicProviderFns => {
|
|||||||
|
|
||||||
const username = generateUsername(usernameTemplate, identity);
|
const username = generateUsername(usernameTemplate, identity);
|
||||||
const { policyArns, userGroups, policyDocument, awsPath, permissionBoundaryPolicyArn } = providerInputs;
|
const { policyArns, userGroups, policyDocument, awsPath, permissionBoundaryPolicyArn } = providerInputs;
|
||||||
|
const awsTags = [{ Key: "createdBy", Value: "infisical-dynamic-secret" }];
|
||||||
|
|
||||||
|
if (providerInputs.tags && Array.isArray(providerInputs.tags)) {
|
||||||
|
const additionalTags = providerInputs.tags.map((tag) => ({
|
||||||
|
Key: tag.key,
|
||||||
|
Value: tag.value
|
||||||
|
}));
|
||||||
|
awsTags.push(...additionalTags);
|
||||||
|
}
|
||||||
|
|
||||||
const createUserRes = await client.send(
|
const createUserRes = await client.send(
|
||||||
new CreateUserCommand({
|
new CreateUserCommand({
|
||||||
Path: awsPath,
|
Path: awsPath,
|
||||||
PermissionsBoundary: permissionBoundaryPolicyArn || undefined,
|
PermissionsBoundary: permissionBoundaryPolicyArn || undefined,
|
||||||
Tags: [{ Key: "createdBy", Value: "infisical-dynamic-secret" }],
|
Tags: awsTags,
|
||||||
UserName: username
|
UserName: username
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
import axios from "axios";
|
||||||
|
import * as jwt from "jsonwebtoken";
|
||||||
|
|
||||||
|
import { BadRequestError, InternalServerError } from "@app/lib/errors";
|
||||||
|
import { alphaNumericNanoId } from "@app/lib/nanoid";
|
||||||
|
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
|
||||||
|
|
||||||
|
import { DynamicSecretGithubSchema, TDynamicProviderFns } from "./models";
|
||||||
|
|
||||||
|
interface GitHubInstallationTokenResponse {
|
||||||
|
token: string;
|
||||||
|
expires_at: string; // ISO 8601 timestamp e.g., "2024-01-15T12:00:00Z"
|
||||||
|
permissions?: Record<string, string>;
|
||||||
|
repository_selection?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TGithubProviderInputs {
|
||||||
|
appId: number;
|
||||||
|
installationId: number;
|
||||||
|
privateKey: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const GithubProvider = (): TDynamicProviderFns => {
|
||||||
|
const validateProviderInputs = async (inputs: unknown) => {
|
||||||
|
const providerInputs = await DynamicSecretGithubSchema.parseAsync(inputs);
|
||||||
|
return providerInputs;
|
||||||
|
};
|
||||||
|
|
||||||
|
const $generateGitHubInstallationAccessToken = async (
|
||||||
|
credentials: TGithubProviderInputs
|
||||||
|
): Promise<GitHubInstallationTokenResponse> => {
|
||||||
|
const { appId, installationId, privateKey } = credentials;
|
||||||
|
|
||||||
|
const nowInSeconds = Math.floor(Date.now() / 1000);
|
||||||
|
const jwtPayload = {
|
||||||
|
iat: nowInSeconds - 5,
|
||||||
|
exp: nowInSeconds + 60,
|
||||||
|
iss: String(appId)
|
||||||
|
};
|
||||||
|
|
||||||
|
let appJwt: string;
|
||||||
|
try {
|
||||||
|
appJwt = jwt.sign(jwtPayload, privateKey, { algorithm: "RS256" });
|
||||||
|
} catch (error) {
|
||||||
|
let message = "Failed to sign JWT.";
|
||||||
|
if (error instanceof jwt.JsonWebTokenError) {
|
||||||
|
message += ` JsonWebTokenError: ${error.message}`;
|
||||||
|
}
|
||||||
|
throw new InternalServerError({
|
||||||
|
message
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const tokenUrl = `${IntegrationUrls.GITHUB_API_URL}/app/installations/${String(installationId)}/access_tokens`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await axios.post<GitHubInstallationTokenResponse>(tokenUrl, undefined, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${appJwt}`,
|
||||||
|
Accept: "application/vnd.github.v3+json",
|
||||||
|
"X-GitHub-Api-Version": "2022-11-28"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.status === 201 && response.data.token) {
|
||||||
|
return response.data; // Includes token, expires_at, permissions, repository_selection
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new InternalServerError({
|
||||||
|
message: `GitHub API responded with unexpected status ${response.status}: ${JSON.stringify(response.data)}`
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
let message = "Failed to fetch GitHub installation access token.";
|
||||||
|
if (axios.isAxiosError(error) && error.response) {
|
||||||
|
const githubErrorMsg =
|
||||||
|
(error.response.data as { message?: string })?.message || JSON.stringify(error.response.data);
|
||||||
|
message += ` GitHub API Error: ${error.response.status} - ${githubErrorMsg}`;
|
||||||
|
|
||||||
|
// Classify as BadRequestError for auth-related issues (401, 403, 404) which might be due to user input
|
||||||
|
if ([401, 403, 404].includes(error.response.status)) {
|
||||||
|
throw new BadRequestError({ message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new InternalServerError({ message });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const validateConnection = async (inputs: unknown) => {
|
||||||
|
const providerInputs = await validateProviderInputs(inputs);
|
||||||
|
await $generateGitHubInstallationAccessToken(providerInputs);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const create = async (data: { inputs: unknown }) => {
|
||||||
|
const { inputs } = data;
|
||||||
|
const providerInputs = await validateProviderInputs(inputs);
|
||||||
|
|
||||||
|
const ghTokenData = await $generateGitHubInstallationAccessToken(providerInputs);
|
||||||
|
const entityId = alphaNumericNanoId(32);
|
||||||
|
|
||||||
|
return {
|
||||||
|
entityId,
|
||||||
|
data: {
|
||||||
|
TOKEN: ghTokenData.token,
|
||||||
|
EXPIRES_AT: ghTokenData.expires_at,
|
||||||
|
PERMISSIONS: ghTokenData.permissions,
|
||||||
|
REPOSITORY_SELECTION: ghTokenData.repository_selection
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const revoke = async () => {
|
||||||
|
// GitHub installation tokens cannot be revoked.
|
||||||
|
throw new BadRequestError({
|
||||||
|
message:
|
||||||
|
"Github dynamic secret does not support revocation because GitHub itself cannot revoke installation tokens"
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const renew = async () => {
|
||||||
|
// No renewal
|
||||||
|
throw new BadRequestError({ message: "Github dynamic secret does not support renewal" });
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
validateProviderInputs,
|
||||||
|
validateConnection,
|
||||||
|
create,
|
||||||
|
revoke,
|
||||||
|
renew
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -7,6 +7,7 @@ import { AzureEntraIDProvider } from "./azure-entra-id";
|
|||||||
import { CassandraProvider } from "./cassandra";
|
import { CassandraProvider } from "./cassandra";
|
||||||
import { ElasticSearchProvider } from "./elastic-search";
|
import { ElasticSearchProvider } from "./elastic-search";
|
||||||
import { GcpIamProvider } from "./gcp-iam";
|
import { GcpIamProvider } from "./gcp-iam";
|
||||||
|
import { GithubProvider } from "./github";
|
||||||
import { KubernetesProvider } from "./kubernetes";
|
import { KubernetesProvider } from "./kubernetes";
|
||||||
import { LdapProvider } from "./ldap";
|
import { LdapProvider } from "./ldap";
|
||||||
import { DynamicSecretProviders, TDynamicProviderFns } from "./models";
|
import { DynamicSecretProviders, TDynamicProviderFns } from "./models";
|
||||||
@@ -44,5 +45,6 @@ export const buildDynamicSecretProviders = ({
|
|||||||
[DynamicSecretProviders.SapAse]: SapAseProvider(),
|
[DynamicSecretProviders.SapAse]: SapAseProvider(),
|
||||||
[DynamicSecretProviders.Kubernetes]: KubernetesProvider({ gatewayService }),
|
[DynamicSecretProviders.Kubernetes]: KubernetesProvider({ gatewayService }),
|
||||||
[DynamicSecretProviders.Vertica]: VerticaProvider({ gatewayService }),
|
[DynamicSecretProviders.Vertica]: VerticaProvider({ gatewayService }),
|
||||||
[DynamicSecretProviders.GcpIam]: GcpIamProvider()
|
[DynamicSecretProviders.GcpIam]: GcpIamProvider(),
|
||||||
|
[DynamicSecretProviders.Github]: GithubProvider()
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import RE2 from "re2";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { CharacterType, characterValidator } from "@app/lib/validator/validate-string";
|
import { CharacterType, characterValidator } from "@app/lib/validator/validate-string";
|
||||||
|
import { ResourceMetadataSchema } from "@app/services/resource-metadata/resource-metadata-schema";
|
||||||
|
|
||||||
import { TDynamicSecretLeaseConfig } from "../../dynamic-secret-lease/dynamic-secret-lease-types";
|
import { TDynamicSecretLeaseConfig } from "../../dynamic-secret-lease/dynamic-secret-lease-types";
|
||||||
|
|
||||||
@@ -207,7 +208,8 @@ export const DynamicSecretAwsIamSchema = z.preprocess(
|
|||||||
permissionBoundaryPolicyArn: z.string().trim().optional(),
|
permissionBoundaryPolicyArn: z.string().trim().optional(),
|
||||||
policyDocument: z.string().trim().optional(),
|
policyDocument: z.string().trim().optional(),
|
||||||
userGroups: z.string().trim().optional(),
|
userGroups: z.string().trim().optional(),
|
||||||
policyArns: z.string().trim().optional()
|
policyArns: z.string().trim().optional(),
|
||||||
|
tags: ResourceMetadataSchema.optional()
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
method: z.literal(AwsIamAuthType.AssumeRole),
|
method: z.literal(AwsIamAuthType.AssumeRole),
|
||||||
@@ -217,7 +219,8 @@ export const DynamicSecretAwsIamSchema = z.preprocess(
|
|||||||
permissionBoundaryPolicyArn: z.string().trim().optional(),
|
permissionBoundaryPolicyArn: z.string().trim().optional(),
|
||||||
policyDocument: z.string().trim().optional(),
|
policyDocument: z.string().trim().optional(),
|
||||||
userGroups: z.string().trim().optional(),
|
userGroups: z.string().trim().optional(),
|
||||||
policyArns: z.string().trim().optional()
|
policyArns: z.string().trim().optional(),
|
||||||
|
tags: ResourceMetadataSchema.optional()
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
@@ -474,6 +477,23 @@ export const DynamicSecretGcpIamSchema = z.object({
|
|||||||
serviceAccountEmail: z.string().email().trim().min(1, "Service account email required").max(128)
|
serviceAccountEmail: z.string().email().trim().min(1, "Service account email required").max(128)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const DynamicSecretGithubSchema = z.object({
|
||||||
|
appId: z.number().min(1).describe("The ID of your GitHub App."),
|
||||||
|
installationId: z.number().min(1).describe("The ID of the GitHub App installation."),
|
||||||
|
privateKey: z
|
||||||
|
.string()
|
||||||
|
.trim()
|
||||||
|
.min(1)
|
||||||
|
.refine(
|
||||||
|
(val) =>
|
||||||
|
new RE2(
|
||||||
|
/^-----BEGIN(?:(?: RSA| PGP| ENCRYPTED)? PRIVATE KEY)-----\s*[\s\S]*?-----END(?:(?: RSA| PGP| ENCRYPTED)? PRIVATE KEY)-----$/
|
||||||
|
).test(val),
|
||||||
|
"Invalid PEM format for private key"
|
||||||
|
)
|
||||||
|
.describe("The private key generated for your GitHub App.")
|
||||||
|
});
|
||||||
|
|
||||||
export enum DynamicSecretProviders {
|
export enum DynamicSecretProviders {
|
||||||
SqlDatabase = "sql-database",
|
SqlDatabase = "sql-database",
|
||||||
Cassandra = "cassandra",
|
Cassandra = "cassandra",
|
||||||
@@ -492,7 +512,8 @@ export enum DynamicSecretProviders {
|
|||||||
SapAse = "sap-ase",
|
SapAse = "sap-ase",
|
||||||
Kubernetes = "kubernetes",
|
Kubernetes = "kubernetes",
|
||||||
Vertica = "vertica",
|
Vertica = "vertica",
|
||||||
GcpIam = "gcp-iam"
|
GcpIam = "gcp-iam",
|
||||||
|
Github = "github"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DynamicSecretProviderSchema = z.discriminatedUnion("type", [
|
export const DynamicSecretProviderSchema = z.discriminatedUnion("type", [
|
||||||
@@ -513,7 +534,8 @@ export const DynamicSecretProviderSchema = z.discriminatedUnion("type", [
|
|||||||
z.object({ type: z.literal(DynamicSecretProviders.Totp), inputs: DynamicSecretTotpSchema }),
|
z.object({ type: z.literal(DynamicSecretProviders.Totp), inputs: DynamicSecretTotpSchema }),
|
||||||
z.object({ type: z.literal(DynamicSecretProviders.Kubernetes), inputs: DynamicSecretKubernetesSchema }),
|
z.object({ type: z.literal(DynamicSecretProviders.Kubernetes), inputs: DynamicSecretKubernetesSchema }),
|
||||||
z.object({ type: z.literal(DynamicSecretProviders.Vertica), inputs: DynamicSecretVerticaSchema }),
|
z.object({ type: z.literal(DynamicSecretProviders.Vertica), inputs: DynamicSecretVerticaSchema }),
|
||||||
z.object({ type: z.literal(DynamicSecretProviders.GcpIam), inputs: DynamicSecretGcpIamSchema })
|
z.object({ type: z.literal(DynamicSecretProviders.GcpIam), inputs: DynamicSecretGcpIamSchema }),
|
||||||
|
z.object({ type: z.literal(DynamicSecretProviders.Github), inputs: DynamicSecretGithubSchema })
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export type TDynamicProviderFns = {
|
export type TDynamicProviderFns = {
|
||||||
|
|||||||
@@ -2390,6 +2390,10 @@ export const SecretSyncs = {
|
|||||||
ONEPASS: {
|
ONEPASS: {
|
||||||
vaultId: "The ID of the 1Password vault to sync secrets to."
|
vaultId: "The ID of the 1Password vault to sync secrets to."
|
||||||
},
|
},
|
||||||
|
HEROKU: {
|
||||||
|
app: "The ID of the Heroku app to sync secrets to.",
|
||||||
|
appName: "The name of the Heroku app to sync secrets to."
|
||||||
|
},
|
||||||
RENDER: {
|
RENDER: {
|
||||||
serviceId: "The ID of the Render service to sync secrets to.",
|
serviceId: "The ID of the Render service to sync secrets to.",
|
||||||
scope: "The Render scope that secrets should be synced to.",
|
scope: "The Render scope that secrets should be synced to.",
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import {
|
|||||||
HCVaultConnectionListItemSchema,
|
HCVaultConnectionListItemSchema,
|
||||||
SanitizedHCVaultConnectionSchema
|
SanitizedHCVaultConnectionSchema
|
||||||
} from "@app/services/app-connection/hc-vault";
|
} from "@app/services/app-connection/hc-vault";
|
||||||
|
import { HerokuConnectionListItemSchema, SanitizedHerokuConnectionSchema } from "@app/services/app-connection/heroku";
|
||||||
import {
|
import {
|
||||||
HumanitecConnectionListItemSchema,
|
HumanitecConnectionListItemSchema,
|
||||||
SanitizedHumanitecConnectionSchema
|
SanitizedHumanitecConnectionSchema
|
||||||
@@ -110,6 +111,7 @@ const SanitizedAppConnectionSchema = z.union([
|
|||||||
...SanitizedOCIConnectionSchema.options,
|
...SanitizedOCIConnectionSchema.options,
|
||||||
...SanitizedOracleDBConnectionSchema.options,
|
...SanitizedOracleDBConnectionSchema.options,
|
||||||
...SanitizedOnePassConnectionSchema.options,
|
...SanitizedOnePassConnectionSchema.options,
|
||||||
|
...SanitizedHerokuConnectionSchema.options,
|
||||||
...SanitizedRenderConnectionSchema.options,
|
...SanitizedRenderConnectionSchema.options,
|
||||||
...SanitizedFlyioConnectionSchema.options,
|
...SanitizedFlyioConnectionSchema.options,
|
||||||
...SanitizedCloudflareConnectionSchema.options
|
...SanitizedCloudflareConnectionSchema.options
|
||||||
@@ -140,6 +142,7 @@ const AppConnectionOptionsSchema = z.discriminatedUnion("app", [
|
|||||||
OCIConnectionListItemSchema,
|
OCIConnectionListItemSchema,
|
||||||
OracleDBConnectionListItemSchema,
|
OracleDBConnectionListItemSchema,
|
||||||
OnePassConnectionListItemSchema,
|
OnePassConnectionListItemSchema,
|
||||||
|
HerokuConnectionListItemSchema,
|
||||||
RenderConnectionListItemSchema,
|
RenderConnectionListItemSchema,
|
||||||
FlyioConnectionListItemSchema,
|
FlyioConnectionListItemSchema,
|
||||||
CloudflareConnectionListItemSchema
|
CloudflareConnectionListItemSchema
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import z from "zod";
|
||||||
|
|
||||||
|
import { readLimit } from "@app/server/config/rateLimiter";
|
||||||
|
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||||
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
import {
|
||||||
|
CreateHerokuConnectionSchema,
|
||||||
|
SanitizedHerokuConnectionSchema,
|
||||||
|
THerokuApp,
|
||||||
|
UpdateHerokuConnectionSchema
|
||||||
|
} from "@app/services/app-connection/heroku";
|
||||||
|
import { AuthMode } from "@app/services/auth/auth-type";
|
||||||
|
|
||||||
|
import { registerAppConnectionEndpoints } from "./app-connection-endpoints";
|
||||||
|
|
||||||
|
export const registerHerokuConnectionRouter = async (server: FastifyZodProvider) => {
|
||||||
|
registerAppConnectionEndpoints({
|
||||||
|
app: AppConnection.Heroku,
|
||||||
|
server,
|
||||||
|
sanitizedResponseSchema: SanitizedHerokuConnectionSchema,
|
||||||
|
createSchema: CreateHerokuConnectionSchema,
|
||||||
|
updateSchema: UpdateHerokuConnectionSchema
|
||||||
|
});
|
||||||
|
|
||||||
|
// The below endpoints are not exposed and for Infisical App use
|
||||||
|
server.route({
|
||||||
|
method: "GET",
|
||||||
|
url: `/:connectionId/apps`,
|
||||||
|
config: {
|
||||||
|
rateLimit: readLimit
|
||||||
|
},
|
||||||
|
schema: {
|
||||||
|
params: z.object({
|
||||||
|
connectionId: z.string().uuid()
|
||||||
|
}),
|
||||||
|
response: {
|
||||||
|
200: z
|
||||||
|
.object({
|
||||||
|
id: z.string(),
|
||||||
|
name: z.string()
|
||||||
|
})
|
||||||
|
.array()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onRequest: verifyAuth([AuthMode.JWT]),
|
||||||
|
handler: async (req) => {
|
||||||
|
const { connectionId } = req.params;
|
||||||
|
|
||||||
|
const apps: THerokuApp[] = await server.services.appConnection.heroku.listApps(connectionId, req.permission);
|
||||||
|
|
||||||
|
return apps;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -16,6 +16,7 @@ import { registerGcpConnectionRouter } from "./gcp-connection-router";
|
|||||||
import { registerGitHubConnectionRouter } from "./github-connection-router";
|
import { registerGitHubConnectionRouter } from "./github-connection-router";
|
||||||
import { registerGitHubRadarConnectionRouter } from "./github-radar-connection-router";
|
import { registerGitHubRadarConnectionRouter } from "./github-radar-connection-router";
|
||||||
import { registerHCVaultConnectionRouter } from "./hc-vault-connection-router";
|
import { registerHCVaultConnectionRouter } from "./hc-vault-connection-router";
|
||||||
|
import { registerHerokuConnectionRouter } from "./heroku-connection-router";
|
||||||
import { registerHumanitecConnectionRouter } from "./humanitec-connection-router";
|
import { registerHumanitecConnectionRouter } from "./humanitec-connection-router";
|
||||||
import { registerLdapConnectionRouter } from "./ldap-connection-router";
|
import { registerLdapConnectionRouter } from "./ldap-connection-router";
|
||||||
import { registerMsSqlConnectionRouter } from "./mssql-connection-router";
|
import { registerMsSqlConnectionRouter } from "./mssql-connection-router";
|
||||||
@@ -56,6 +57,7 @@ export const APP_CONNECTION_REGISTER_ROUTER_MAP: Record<AppConnection, (server:
|
|||||||
[AppConnection.OCI]: registerOCIConnectionRouter,
|
[AppConnection.OCI]: registerOCIConnectionRouter,
|
||||||
[AppConnection.OracleDB]: registerOracleDBConnectionRouter,
|
[AppConnection.OracleDB]: registerOracleDBConnectionRouter,
|
||||||
[AppConnection.OnePass]: registerOnePassConnectionRouter,
|
[AppConnection.OnePass]: registerOnePassConnectionRouter,
|
||||||
|
[AppConnection.Heroku]: registerHerokuConnectionRouter,
|
||||||
[AppConnection.Render]: registerRenderConnectionRouter,
|
[AppConnection.Render]: registerRenderConnectionRouter,
|
||||||
[AppConnection.Flyio]: registerFlyioConnectionRouter,
|
[AppConnection.Flyio]: registerFlyioConnectionRouter,
|
||||||
[AppConnection.Cloudflare]: registerCloudflareConnectionRouter
|
[AppConnection.Cloudflare]: registerCloudflareConnectionRouter
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { CreateHerokuSyncSchema, HerokuSyncSchema, UpdateHerokuSyncSchema } from "@app/services/secret-sync/heroku";
|
||||||
|
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
|
|
||||||
|
import { registerSyncSecretsEndpoints } from "./secret-sync-endpoints";
|
||||||
|
|
||||||
|
export const registerHerokuSyncRouter = async (server: FastifyZodProvider) =>
|
||||||
|
registerSyncSecretsEndpoints({
|
||||||
|
destination: SecretSync.Heroku,
|
||||||
|
server,
|
||||||
|
responseSchema: HerokuSyncSchema,
|
||||||
|
createSchema: CreateHerokuSyncSchema,
|
||||||
|
updateSchema: UpdateHerokuSyncSchema
|
||||||
|
});
|
||||||
@@ -13,6 +13,7 @@ import { registerFlyioSyncRouter } from "./flyio-sync-router";
|
|||||||
import { registerGcpSyncRouter } from "./gcp-sync-router";
|
import { registerGcpSyncRouter } from "./gcp-sync-router";
|
||||||
import { registerGitHubSyncRouter } from "./github-sync-router";
|
import { registerGitHubSyncRouter } from "./github-sync-router";
|
||||||
import { registerHCVaultSyncRouter } from "./hc-vault-sync-router";
|
import { registerHCVaultSyncRouter } from "./hc-vault-sync-router";
|
||||||
|
import { registerHerokuSyncRouter } from "./heroku-sync-router";
|
||||||
import { registerHumanitecSyncRouter } from "./humanitec-sync-router";
|
import { registerHumanitecSyncRouter } from "./humanitec-sync-router";
|
||||||
import { registerRenderSyncRouter } from "./render-sync-router";
|
import { registerRenderSyncRouter } from "./render-sync-router";
|
||||||
import { registerTeamCitySyncRouter } from "./teamcity-sync-router";
|
import { registerTeamCitySyncRouter } from "./teamcity-sync-router";
|
||||||
@@ -41,6 +42,7 @@ export const SECRET_SYNC_REGISTER_ROUTER_MAP: Record<SecretSync, (server: Fastif
|
|||||||
[SecretSync.TeamCity]: registerTeamCitySyncRouter,
|
[SecretSync.TeamCity]: registerTeamCitySyncRouter,
|
||||||
[SecretSync.OCIVault]: registerOCIVaultSyncRouter,
|
[SecretSync.OCIVault]: registerOCIVaultSyncRouter,
|
||||||
[SecretSync.OnePass]: registerOnePassSyncRouter,
|
[SecretSync.OnePass]: registerOnePassSyncRouter,
|
||||||
|
[SecretSync.Heroku]: registerHerokuSyncRouter,
|
||||||
[SecretSync.Render]: registerRenderSyncRouter,
|
[SecretSync.Render]: registerRenderSyncRouter,
|
||||||
[SecretSync.Flyio]: registerFlyioSyncRouter,
|
[SecretSync.Flyio]: registerFlyioSyncRouter,
|
||||||
[SecretSync.CloudflarePages]: registerCloudflarePagesSyncRouter
|
[SecretSync.CloudflarePages]: registerCloudflarePagesSyncRouter
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import { FlyioSyncListItemSchema, FlyioSyncSchema } from "@app/services/secret-s
|
|||||||
import { GcpSyncListItemSchema, GcpSyncSchema } from "@app/services/secret-sync/gcp";
|
import { GcpSyncListItemSchema, GcpSyncSchema } from "@app/services/secret-sync/gcp";
|
||||||
import { GitHubSyncListItemSchema, GitHubSyncSchema } from "@app/services/secret-sync/github";
|
import { GitHubSyncListItemSchema, GitHubSyncSchema } from "@app/services/secret-sync/github";
|
||||||
import { HCVaultSyncListItemSchema, HCVaultSyncSchema } from "@app/services/secret-sync/hc-vault";
|
import { HCVaultSyncListItemSchema, HCVaultSyncSchema } from "@app/services/secret-sync/hc-vault";
|
||||||
|
import { HerokuSyncListItemSchema, HerokuSyncSchema } from "@app/services/secret-sync/heroku";
|
||||||
import { HumanitecSyncListItemSchema, HumanitecSyncSchema } from "@app/services/secret-sync/humanitec";
|
import { HumanitecSyncListItemSchema, HumanitecSyncSchema } from "@app/services/secret-sync/humanitec";
|
||||||
import { RenderSyncListItemSchema, RenderSyncSchema } from "@app/services/secret-sync/render/render-sync-schemas";
|
import { RenderSyncListItemSchema, RenderSyncSchema } from "@app/services/secret-sync/render/render-sync-schemas";
|
||||||
import { TeamCitySyncListItemSchema, TeamCitySyncSchema } from "@app/services/secret-sync/teamcity";
|
import { TeamCitySyncListItemSchema, TeamCitySyncSchema } from "@app/services/secret-sync/teamcity";
|
||||||
@@ -56,6 +57,7 @@ const SecretSyncSchema = z.discriminatedUnion("destination", [
|
|||||||
TeamCitySyncSchema,
|
TeamCitySyncSchema,
|
||||||
OCIVaultSyncSchema,
|
OCIVaultSyncSchema,
|
||||||
OnePassSyncSchema,
|
OnePassSyncSchema,
|
||||||
|
HerokuSyncSchema,
|
||||||
RenderSyncSchema,
|
RenderSyncSchema,
|
||||||
FlyioSyncSchema,
|
FlyioSyncSchema,
|
||||||
CloudflarePagesSyncSchema
|
CloudflarePagesSyncSchema
|
||||||
@@ -79,6 +81,7 @@ const SecretSyncOptionsSchema = z.discriminatedUnion("destination", [
|
|||||||
TeamCitySyncListItemSchema,
|
TeamCitySyncListItemSchema,
|
||||||
OCIVaultSyncListItemSchema,
|
OCIVaultSyncListItemSchema,
|
||||||
OnePassSyncListItemSchema,
|
OnePassSyncListItemSchema,
|
||||||
|
HerokuSyncListItemSchema,
|
||||||
RenderSyncListItemSchema,
|
RenderSyncListItemSchema,
|
||||||
FlyioSyncListItemSchema,
|
FlyioSyncListItemSchema,
|
||||||
CloudflarePagesSyncListItemSchema
|
CloudflarePagesSyncListItemSchema
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export enum AppConnection {
|
|||||||
OCI = "oci",
|
OCI = "oci",
|
||||||
OracleDB = "oracledb",
|
OracleDB = "oracledb",
|
||||||
OnePass = "1password",
|
OnePass = "1password",
|
||||||
|
Heroku = "heroku",
|
||||||
Render = "render",
|
Render = "render",
|
||||||
Flyio = "flyio",
|
Flyio = "flyio",
|
||||||
Cloudflare = "cloudflare"
|
Cloudflare = "cloudflare"
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ import {
|
|||||||
HCVaultConnectionMethod,
|
HCVaultConnectionMethod,
|
||||||
validateHCVaultConnectionCredentials
|
validateHCVaultConnectionCredentials
|
||||||
} from "./hc-vault";
|
} from "./hc-vault";
|
||||||
|
import { getHerokuConnectionListItem, HerokuConnectionMethod, validateHerokuConnectionCredentials } from "./heroku";
|
||||||
import {
|
import {
|
||||||
getHumanitecConnectionListItem,
|
getHumanitecConnectionListItem,
|
||||||
HumanitecConnectionMethod,
|
HumanitecConnectionMethod,
|
||||||
@@ -130,6 +131,7 @@ export const listAppConnectionOptions = () => {
|
|||||||
getOCIConnectionListItem(),
|
getOCIConnectionListItem(),
|
||||||
getOracleDBConnectionListItem(),
|
getOracleDBConnectionListItem(),
|
||||||
getOnePassConnectionListItem(),
|
getOnePassConnectionListItem(),
|
||||||
|
getHerokuConnectionListItem(),
|
||||||
getRenderConnectionListItem(),
|
getRenderConnectionListItem(),
|
||||||
getFlyioConnectionListItem(),
|
getFlyioConnectionListItem(),
|
||||||
getCloudflareConnectionListItem()
|
getCloudflareConnectionListItem()
|
||||||
@@ -208,6 +210,7 @@ export const validateAppConnectionCredentials = async (
|
|||||||
[AppConnection.OCI]: validateOCIConnectionCredentials as TAppConnectionCredentialsValidator,
|
[AppConnection.OCI]: validateOCIConnectionCredentials as TAppConnectionCredentialsValidator,
|
||||||
[AppConnection.OracleDB]: validateSqlConnectionCredentials as TAppConnectionCredentialsValidator,
|
[AppConnection.OracleDB]: validateSqlConnectionCredentials as TAppConnectionCredentialsValidator,
|
||||||
[AppConnection.OnePass]: validateOnePassConnectionCredentials as TAppConnectionCredentialsValidator,
|
[AppConnection.OnePass]: validateOnePassConnectionCredentials as TAppConnectionCredentialsValidator,
|
||||||
|
[AppConnection.Heroku]: validateHerokuConnectionCredentials as TAppConnectionCredentialsValidator,
|
||||||
[AppConnection.Render]: validateRenderConnectionCredentials as TAppConnectionCredentialsValidator,
|
[AppConnection.Render]: validateRenderConnectionCredentials as TAppConnectionCredentialsValidator,
|
||||||
[AppConnection.Flyio]: validateFlyioConnectionCredentials as TAppConnectionCredentialsValidator,
|
[AppConnection.Flyio]: validateFlyioConnectionCredentials as TAppConnectionCredentialsValidator,
|
||||||
[AppConnection.Cloudflare]: validateCloudflareConnectionCredentials as TAppConnectionCredentialsValidator
|
[AppConnection.Cloudflare]: validateCloudflareConnectionCredentials as TAppConnectionCredentialsValidator
|
||||||
@@ -226,7 +229,10 @@ export const getAppConnectionMethodName = (method: TAppConnection["method"]) =>
|
|||||||
case AzureClientSecretsConnectionMethod.OAuth:
|
case AzureClientSecretsConnectionMethod.OAuth:
|
||||||
case GitHubConnectionMethod.OAuth:
|
case GitHubConnectionMethod.OAuth:
|
||||||
case AzureDevOpsConnectionMethod.OAuth:
|
case AzureDevOpsConnectionMethod.OAuth:
|
||||||
|
case HerokuConnectionMethod.OAuth:
|
||||||
return "OAuth";
|
return "OAuth";
|
||||||
|
case HerokuConnectionMethod.AuthToken:
|
||||||
|
return "Auth Token";
|
||||||
case AwsConnectionMethod.AccessKey:
|
case AwsConnectionMethod.AccessKey:
|
||||||
case OCIConnectionMethod.AccessKey:
|
case OCIConnectionMethod.AccessKey:
|
||||||
return "Access Key";
|
return "Access Key";
|
||||||
@@ -318,6 +324,7 @@ export const TRANSITION_CONNECTION_CREDENTIALS_TO_PLATFORM: Record<
|
|||||||
[AppConnection.OCI]: platformManagedCredentialsNotSupported,
|
[AppConnection.OCI]: platformManagedCredentialsNotSupported,
|
||||||
[AppConnection.OracleDB]: transferSqlConnectionCredentialsToPlatform as TAppConnectionTransitionCredentialsToPlatform,
|
[AppConnection.OracleDB]: transferSqlConnectionCredentialsToPlatform as TAppConnectionTransitionCredentialsToPlatform,
|
||||||
[AppConnection.OnePass]: platformManagedCredentialsNotSupported,
|
[AppConnection.OnePass]: platformManagedCredentialsNotSupported,
|
||||||
|
[AppConnection.Heroku]: platformManagedCredentialsNotSupported,
|
||||||
[AppConnection.Render]: platformManagedCredentialsNotSupported,
|
[AppConnection.Render]: platformManagedCredentialsNotSupported,
|
||||||
[AppConnection.Flyio]: platformManagedCredentialsNotSupported,
|
[AppConnection.Flyio]: platformManagedCredentialsNotSupported,
|
||||||
[AppConnection.Cloudflare]: platformManagedCredentialsNotSupported
|
[AppConnection.Cloudflare]: platformManagedCredentialsNotSupported
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export const APP_CONNECTION_NAME_MAP: Record<AppConnection, string> = {
|
|||||||
[AppConnection.OCI]: "OCI",
|
[AppConnection.OCI]: "OCI",
|
||||||
[AppConnection.OracleDB]: "OracleDB",
|
[AppConnection.OracleDB]: "OracleDB",
|
||||||
[AppConnection.OnePass]: "1Password",
|
[AppConnection.OnePass]: "1Password",
|
||||||
|
[AppConnection.Heroku]: "Heroku",
|
||||||
[AppConnection.Render]: "Render",
|
[AppConnection.Render]: "Render",
|
||||||
[AppConnection.Flyio]: "Fly.io",
|
[AppConnection.Flyio]: "Fly.io",
|
||||||
[AppConnection.Cloudflare]: "Cloudflare"
|
[AppConnection.Cloudflare]: "Cloudflare"
|
||||||
@@ -55,6 +56,7 @@ export const APP_CONNECTION_PLAN_MAP: Record<AppConnection, AppConnectionPlanTyp
|
|||||||
[AppConnection.OracleDB]: AppConnectionPlanType.Enterprise,
|
[AppConnection.OracleDB]: AppConnectionPlanType.Enterprise,
|
||||||
[AppConnection.OnePass]: AppConnectionPlanType.Regular,
|
[AppConnection.OnePass]: AppConnectionPlanType.Regular,
|
||||||
[AppConnection.MySql]: AppConnectionPlanType.Regular,
|
[AppConnection.MySql]: AppConnectionPlanType.Regular,
|
||||||
|
[AppConnection.Heroku]: AppConnectionPlanType.Regular,
|
||||||
[AppConnection.Render]: AppConnectionPlanType.Regular,
|
[AppConnection.Render]: AppConnectionPlanType.Regular,
|
||||||
[AppConnection.Flyio]: AppConnectionPlanType.Regular,
|
[AppConnection.Flyio]: AppConnectionPlanType.Regular,
|
||||||
[AppConnection.Cloudflare]: AppConnectionPlanType.Regular
|
[AppConnection.Cloudflare]: AppConnectionPlanType.Regular
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ import { githubConnectionService } from "./github/github-connection-service";
|
|||||||
import { ValidateGitHubRadarConnectionCredentialsSchema } from "./github-radar";
|
import { ValidateGitHubRadarConnectionCredentialsSchema } from "./github-radar";
|
||||||
import { ValidateHCVaultConnectionCredentialsSchema } from "./hc-vault";
|
import { ValidateHCVaultConnectionCredentialsSchema } from "./hc-vault";
|
||||||
import { hcVaultConnectionService } from "./hc-vault/hc-vault-connection-service";
|
import { hcVaultConnectionService } from "./hc-vault/hc-vault-connection-service";
|
||||||
|
import { ValidateHerokuConnectionCredentialsSchema } from "./heroku";
|
||||||
|
import { herokuConnectionService } from "./heroku/heroku-connection-service";
|
||||||
import { ValidateHumanitecConnectionCredentialsSchema } from "./humanitec";
|
import { ValidateHumanitecConnectionCredentialsSchema } from "./humanitec";
|
||||||
import { humanitecConnectionService } from "./humanitec/humanitec-connection-service";
|
import { humanitecConnectionService } from "./humanitec/humanitec-connection-service";
|
||||||
import { ValidateLdapConnectionCredentialsSchema } from "./ldap";
|
import { ValidateLdapConnectionCredentialsSchema } from "./ldap";
|
||||||
@@ -111,6 +113,7 @@ const VALIDATE_APP_CONNECTION_CREDENTIALS_MAP: Record<AppConnection, TValidateAp
|
|||||||
[AppConnection.OCI]: ValidateOCIConnectionCredentialsSchema,
|
[AppConnection.OCI]: ValidateOCIConnectionCredentialsSchema,
|
||||||
[AppConnection.OracleDB]: ValidateOracleDBConnectionCredentialsSchema,
|
[AppConnection.OracleDB]: ValidateOracleDBConnectionCredentialsSchema,
|
||||||
[AppConnection.OnePass]: ValidateOnePassConnectionCredentialsSchema,
|
[AppConnection.OnePass]: ValidateOnePassConnectionCredentialsSchema,
|
||||||
|
[AppConnection.Heroku]: ValidateHerokuConnectionCredentialsSchema,
|
||||||
[AppConnection.Render]: ValidateRenderConnectionCredentialsSchema,
|
[AppConnection.Render]: ValidateRenderConnectionCredentialsSchema,
|
||||||
[AppConnection.Flyio]: ValidateFlyioConnectionCredentialsSchema,
|
[AppConnection.Flyio]: ValidateFlyioConnectionCredentialsSchema,
|
||||||
[AppConnection.Cloudflare]: ValidateCloudflareConnectionCredentialsSchema
|
[AppConnection.Cloudflare]: ValidateCloudflareConnectionCredentialsSchema
|
||||||
@@ -519,6 +522,7 @@ export const appConnectionServiceFactory = ({
|
|||||||
teamcity: teamcityConnectionService(connectAppConnectionById),
|
teamcity: teamcityConnectionService(connectAppConnectionById),
|
||||||
oci: ociConnectionService(connectAppConnectionById, licenseService),
|
oci: ociConnectionService(connectAppConnectionById, licenseService),
|
||||||
onepass: onePassConnectionService(connectAppConnectionById),
|
onepass: onePassConnectionService(connectAppConnectionById),
|
||||||
|
heroku: herokuConnectionService(connectAppConnectionById, appConnectionDAL, kmsService),
|
||||||
render: renderConnectionService(connectAppConnectionById),
|
render: renderConnectionService(connectAppConnectionById),
|
||||||
cloudflare: cloudflareConnectionService(connectAppConnectionById),
|
cloudflare: cloudflareConnectionService(connectAppConnectionById),
|
||||||
flyio: flyioConnectionService(connectAppConnectionById)
|
flyio: flyioConnectionService(connectAppConnectionById)
|
||||||
|
|||||||
@@ -98,6 +98,12 @@ import {
|
|||||||
THCVaultConnectionInput,
|
THCVaultConnectionInput,
|
||||||
TValidateHCVaultConnectionCredentialsSchema
|
TValidateHCVaultConnectionCredentialsSchema
|
||||||
} from "./hc-vault";
|
} from "./hc-vault";
|
||||||
|
import {
|
||||||
|
THerokuConnection,
|
||||||
|
THerokuConnectionConfig,
|
||||||
|
THerokuConnectionInput,
|
||||||
|
TValidateHerokuConnectionCredentialsSchema
|
||||||
|
} from "./heroku";
|
||||||
import {
|
import {
|
||||||
THumanitecConnection,
|
THumanitecConnection,
|
||||||
THumanitecConnectionConfig,
|
THumanitecConnectionConfig,
|
||||||
@@ -179,6 +185,7 @@ export type TAppConnection = { id: string } & (
|
|||||||
| TOCIConnection
|
| TOCIConnection
|
||||||
| TOracleDBConnection
|
| TOracleDBConnection
|
||||||
| TOnePassConnection
|
| TOnePassConnection
|
||||||
|
| THerokuConnection
|
||||||
| TRenderConnection
|
| TRenderConnection
|
||||||
| TFlyioConnection
|
| TFlyioConnection
|
||||||
| TCloudflareConnection
|
| TCloudflareConnection
|
||||||
@@ -213,6 +220,7 @@ export type TAppConnectionInput = { id: string } & (
|
|||||||
| TOCIConnectionInput
|
| TOCIConnectionInput
|
||||||
| TOracleDBConnectionInput
|
| TOracleDBConnectionInput
|
||||||
| TOnePassConnectionInput
|
| TOnePassConnectionInput
|
||||||
|
| THerokuConnectionInput
|
||||||
| TRenderConnectionInput
|
| TRenderConnectionInput
|
||||||
| TFlyioConnectionInput
|
| TFlyioConnectionInput
|
||||||
| TCloudflareConnectionInput
|
| TCloudflareConnectionInput
|
||||||
@@ -255,6 +263,7 @@ export type TAppConnectionConfig =
|
|||||||
| TTeamCityConnectionConfig
|
| TTeamCityConnectionConfig
|
||||||
| TOCIConnectionConfig
|
| TOCIConnectionConfig
|
||||||
| TOnePassConnectionConfig
|
| TOnePassConnectionConfig
|
||||||
|
| THerokuConnectionConfig
|
||||||
| TRenderConnectionConfig
|
| TRenderConnectionConfig
|
||||||
| TFlyioConnectionConfig
|
| TFlyioConnectionConfig
|
||||||
| TCloudflareConnectionConfig;
|
| TCloudflareConnectionConfig;
|
||||||
@@ -284,6 +293,7 @@ export type TValidateAppConnectionCredentialsSchema =
|
|||||||
| TValidateOCIConnectionCredentialsSchema
|
| TValidateOCIConnectionCredentialsSchema
|
||||||
| TValidateOracleDBConnectionCredentialsSchema
|
| TValidateOracleDBConnectionCredentialsSchema
|
||||||
| TValidateOnePassConnectionCredentialsSchema
|
| TValidateOnePassConnectionCredentialsSchema
|
||||||
|
| TValidateHerokuConnectionCredentialsSchema
|
||||||
| TValidateRenderConnectionCredentialsSchema
|
| TValidateRenderConnectionCredentialsSchema
|
||||||
| TValidateFlyioConnectionCredentialsSchema
|
| TValidateFlyioConnectionCredentialsSchema
|
||||||
| TValidateCloudflareConnectionCredentialsSchema;
|
| TValidateCloudflareConnectionCredentialsSchema;
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export enum HerokuConnectionMethod {
|
||||||
|
AuthToken = "auth-token",
|
||||||
|
OAuth = "oauth"
|
||||||
|
}
|
||||||
@@ -0,0 +1,208 @@
|
|||||||
|
import { AxiosError, AxiosResponse } from "axios";
|
||||||
|
|
||||||
|
import { getConfig } from "@app/lib/config/env";
|
||||||
|
import { request } from "@app/lib/config/request";
|
||||||
|
import { BadRequestError, InternalServerError } from "@app/lib/errors";
|
||||||
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
import { encryptAppConnectionCredentials } from "@app/services/app-connection/app-connection-fns";
|
||||||
|
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
|
||||||
|
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
|
||||||
|
|
||||||
|
import { TAppConnectionDALFactory } from "../app-connection-dal";
|
||||||
|
import { HerokuConnectionMethod } from "./heroku-connection-enums";
|
||||||
|
import { THerokuApp, THerokuConnection, THerokuConnectionConfig } from "./heroku-connection-types";
|
||||||
|
|
||||||
|
interface HerokuOAuthTokenResponse {
|
||||||
|
access_token: string;
|
||||||
|
expires_in: number;
|
||||||
|
refresh_token: string;
|
||||||
|
token_type: string;
|
||||||
|
user_id: string;
|
||||||
|
session_nonce: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getHerokuConnectionListItem = () => {
|
||||||
|
const { CLIENT_ID_HEROKU } = getConfig();
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: "Heroku" as const,
|
||||||
|
app: AppConnection.Heroku as const,
|
||||||
|
methods: Object.values(HerokuConnectionMethod) as [HerokuConnectionMethod.AuthToken, HerokuConnectionMethod.OAuth],
|
||||||
|
oauthClientId: CLIENT_ID_HEROKU
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const refreshHerokuToken = async (
|
||||||
|
refreshToken: string,
|
||||||
|
appId: string,
|
||||||
|
orgId: string,
|
||||||
|
appConnectionDAL: Pick<TAppConnectionDALFactory, "updateById">,
|
||||||
|
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">
|
||||||
|
): Promise<string> => {
|
||||||
|
const { CLIENT_SECRET_HEROKU } = getConfig();
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
grant_type: "refresh_token",
|
||||||
|
refresh_token: refreshToken,
|
||||||
|
client_secret: CLIENT_SECRET_HEROKU
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data } = await request.post<{ access_token: string; expires_in: number }>(
|
||||||
|
IntegrationUrls.HEROKU_TOKEN_URL,
|
||||||
|
payload,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const encryptedCredentials = await encryptAppConnectionCredentials({
|
||||||
|
credentials: {
|
||||||
|
refreshToken,
|
||||||
|
authToken: data.access_token,
|
||||||
|
expiresAt: new Date(Date.now() + data.expires_in * 1000 - 60000)
|
||||||
|
},
|
||||||
|
orgId,
|
||||||
|
kmsService
|
||||||
|
});
|
||||||
|
|
||||||
|
await appConnectionDAL.updateById(appId, { encryptedCredentials });
|
||||||
|
|
||||||
|
return data.access_token;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const exchangeHerokuOAuthCode = async (code: string): Promise<HerokuOAuthTokenResponse> => {
|
||||||
|
const { CLIENT_SECRET_HEROKU } = getConfig();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await request.post<HerokuOAuthTokenResponse>(
|
||||||
|
IntegrationUrls.HEROKU_TOKEN_URL,
|
||||||
|
{
|
||||||
|
grant_type: "authorization_code",
|
||||||
|
code,
|
||||||
|
client_secret: CLIENT_SECRET_HEROKU
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!response.data) {
|
||||||
|
throw new InternalServerError({
|
||||||
|
message: "Failed to exchange OAuth code: Empty response"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof AxiosError) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
|
message: `Failed to exchange OAuth code: ${error.response?.data?.message || error.message || "Unknown error"}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: "Unable to exchange OAuth code"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const validateHerokuConnectionCredentials = async (config: THerokuConnectionConfig) => {
|
||||||
|
const { credentials: inputCredentials, method } = config;
|
||||||
|
|
||||||
|
let authToken: string;
|
||||||
|
let oauthData: HerokuOAuthTokenResponse | null = null;
|
||||||
|
|
||||||
|
if (method === HerokuConnectionMethod.OAuth && "code" in inputCredentials) {
|
||||||
|
oauthData = await exchangeHerokuOAuthCode(inputCredentials.code);
|
||||||
|
authToken = oauthData.access_token;
|
||||||
|
} else if (method === HerokuConnectionMethod.AuthToken && "authToken" in inputCredentials) {
|
||||||
|
authToken = inputCredentials.authToken;
|
||||||
|
} else {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: "Invalid credentials for the selected connection method"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let response: AxiosResponse<THerokuApp[]> | null = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
response = await request.get<THerokuApp[]>(`${IntegrationUrls.HEROKU_API_URL}/apps`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${authToken}`,
|
||||||
|
Accept: "application/vnd.heroku+json; version=3"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error: unknown) {
|
||||||
|
if (error instanceof AxiosError) {
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: `Failed to validate credentials: ${error.message || "Unknown error"}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
throw new BadRequestError({
|
||||||
|
message: "Unable to validate connection: verify credentials"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!response?.data) {
|
||||||
|
throw new InternalServerError({
|
||||||
|
message: "Failed to get apps: Response was empty"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method === HerokuConnectionMethod.OAuth && oauthData) {
|
||||||
|
return {
|
||||||
|
authToken,
|
||||||
|
refreshToken: oauthData.refresh_token,
|
||||||
|
expiresIn: oauthData.expires_in,
|
||||||
|
tokenType: oauthData.token_type,
|
||||||
|
userId: oauthData.user_id,
|
||||||
|
sessionNonce: oauthData.session_nonce
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return inputCredentials;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const listHerokuApps = async ({
|
||||||
|
appConnection,
|
||||||
|
appConnectionDAL,
|
||||||
|
kmsService
|
||||||
|
}: {
|
||||||
|
appConnection: THerokuConnection;
|
||||||
|
appConnectionDAL: Pick<TAppConnectionDALFactory, "updateById">;
|
||||||
|
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
|
||||||
|
}): Promise<THerokuApp[]> => {
|
||||||
|
let authCredential = appConnection.credentials.authToken;
|
||||||
|
if (
|
||||||
|
appConnection.method === HerokuConnectionMethod.OAuth &&
|
||||||
|
appConnection.credentials.refreshToken &&
|
||||||
|
appConnection.credentials.expiresAt < new Date()
|
||||||
|
) {
|
||||||
|
authCredential = await refreshHerokuToken(
|
||||||
|
appConnection.credentials.refreshToken,
|
||||||
|
appConnection.id,
|
||||||
|
appConnection.orgId,
|
||||||
|
appConnectionDAL,
|
||||||
|
kmsService
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await request.get<THerokuApp[]>(`${IntegrationUrls.HEROKU_API_URL}/apps`, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${authCredential}`,
|
||||||
|
Accept: "application/vnd.heroku+json; version=3"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
throw new InternalServerError({
|
||||||
|
message: "Failed to get apps: Response was empty"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return data.map((res) => ({ name: res.name, id: res.id }));
|
||||||
|
};
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
import z from "zod";
|
||||||
|
|
||||||
|
import { AppConnections } from "@app/lib/api-docs";
|
||||||
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
import {
|
||||||
|
BaseAppConnectionSchema,
|
||||||
|
GenericCreateAppConnectionFieldsSchema,
|
||||||
|
GenericUpdateAppConnectionFieldsSchema
|
||||||
|
} from "@app/services/app-connection/app-connection-schemas";
|
||||||
|
|
||||||
|
import { HerokuConnectionMethod } from "./heroku-connection-enums";
|
||||||
|
|
||||||
|
export const HerokuConnectionAuthTokenCredentialsSchema = z.object({
|
||||||
|
authToken: z.string().trim().min(1, "Auth Token required").startsWith("HRKU-", "Token must start with 'HRKU-")
|
||||||
|
});
|
||||||
|
|
||||||
|
export const HerokuConnectionOAuthCredentialsSchema = z.object({
|
||||||
|
code: z.string().trim().min(1, "OAuth code required")
|
||||||
|
});
|
||||||
|
|
||||||
|
export const HerokuConnectionOAuthOutputCredentialsSchema = z.object({
|
||||||
|
authToken: z.string().trim(),
|
||||||
|
refreshToken: z.string().trim(),
|
||||||
|
expiresAt: z.date()
|
||||||
|
});
|
||||||
|
|
||||||
|
// Schema for refresh token input during initial setup
|
||||||
|
export const HerokuConnectionRefreshTokenCredentialsSchema = z.object({
|
||||||
|
refreshToken: z.string().trim().min(1, "Refresh token required")
|
||||||
|
});
|
||||||
|
|
||||||
|
const BaseHerokuConnectionSchema = BaseAppConnectionSchema.extend({
|
||||||
|
app: z.literal(AppConnection.Heroku)
|
||||||
|
});
|
||||||
|
|
||||||
|
export const HerokuConnectionSchema = z.intersection(
|
||||||
|
BaseHerokuConnectionSchema,
|
||||||
|
z.discriminatedUnion("method", [
|
||||||
|
z.object({
|
||||||
|
method: z.literal(HerokuConnectionMethod.AuthToken),
|
||||||
|
credentials: HerokuConnectionAuthTokenCredentialsSchema
|
||||||
|
}),
|
||||||
|
z.object({
|
||||||
|
method: z.literal(HerokuConnectionMethod.OAuth),
|
||||||
|
credentials: HerokuConnectionOAuthOutputCredentialsSchema
|
||||||
|
})
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
export const SanitizedHerokuConnectionSchema = z.discriminatedUnion("method", [
|
||||||
|
BaseHerokuConnectionSchema.extend({
|
||||||
|
method: z.literal(HerokuConnectionMethod.AuthToken),
|
||||||
|
credentials: HerokuConnectionAuthTokenCredentialsSchema.pick({})
|
||||||
|
}),
|
||||||
|
BaseHerokuConnectionSchema.extend({
|
||||||
|
method: z.literal(HerokuConnectionMethod.OAuth),
|
||||||
|
credentials: HerokuConnectionOAuthOutputCredentialsSchema.pick({})
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
export const ValidateHerokuConnectionCredentialsSchema = z.discriminatedUnion("method", [
|
||||||
|
z.object({
|
||||||
|
method: z.literal(HerokuConnectionMethod.AuthToken).describe(AppConnections.CREATE(AppConnection.Heroku).method),
|
||||||
|
credentials: HerokuConnectionAuthTokenCredentialsSchema.describe(
|
||||||
|
AppConnections.CREATE(AppConnection.Heroku).credentials
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
z.object({
|
||||||
|
method: z.literal(HerokuConnectionMethod.OAuth).describe(AppConnections.CREATE(AppConnection.Heroku).method),
|
||||||
|
credentials: z
|
||||||
|
.union([
|
||||||
|
HerokuConnectionOAuthCredentialsSchema,
|
||||||
|
HerokuConnectionRefreshTokenCredentialsSchema,
|
||||||
|
HerokuConnectionOAuthOutputCredentialsSchema
|
||||||
|
])
|
||||||
|
.describe(AppConnections.CREATE(AppConnection.Heroku).credentials)
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
export const CreateHerokuConnectionSchema = ValidateHerokuConnectionCredentialsSchema.and(
|
||||||
|
GenericCreateAppConnectionFieldsSchema(AppConnection.Heroku)
|
||||||
|
);
|
||||||
|
|
||||||
|
export const UpdateHerokuConnectionSchema = z
|
||||||
|
.object({
|
||||||
|
credentials: z
|
||||||
|
.union([
|
||||||
|
HerokuConnectionAuthTokenCredentialsSchema,
|
||||||
|
HerokuConnectionOAuthOutputCredentialsSchema,
|
||||||
|
HerokuConnectionRefreshTokenCredentialsSchema,
|
||||||
|
HerokuConnectionOAuthCredentialsSchema
|
||||||
|
])
|
||||||
|
.optional()
|
||||||
|
.describe(AppConnections.UPDATE(AppConnection.Heroku).credentials)
|
||||||
|
})
|
||||||
|
.and(GenericUpdateAppConnectionFieldsSchema(AppConnection.Heroku));
|
||||||
|
|
||||||
|
export const HerokuConnectionListItemSchema = z.object({
|
||||||
|
name: z.literal("Heroku"),
|
||||||
|
app: z.literal(AppConnection.Heroku),
|
||||||
|
methods: z.nativeEnum(HerokuConnectionMethod).array(),
|
||||||
|
oauthClientId: z.string().optional()
|
||||||
|
});
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { logger } from "@app/lib/logger";
|
||||||
|
import { OrgServiceActor } from "@app/lib/types";
|
||||||
|
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
|
||||||
|
|
||||||
|
import { TAppConnectionDALFactory } from "../app-connection-dal";
|
||||||
|
import { AppConnection } from "../app-connection-enums";
|
||||||
|
import { listHerokuApps as getHerokuApps } from "./heroku-connection-fns";
|
||||||
|
import { THerokuConnection } from "./heroku-connection-types";
|
||||||
|
|
||||||
|
type TGetAppConnectionFunc = (
|
||||||
|
app: AppConnection,
|
||||||
|
connectionId: string,
|
||||||
|
actor: OrgServiceActor
|
||||||
|
) => Promise<THerokuConnection>;
|
||||||
|
|
||||||
|
export const herokuConnectionService = (
|
||||||
|
getAppConnection: TGetAppConnectionFunc,
|
||||||
|
appConnectionDAL: Pick<TAppConnectionDALFactory, "updateById">,
|
||||||
|
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">
|
||||||
|
) => {
|
||||||
|
const listApps = async (connectionId: string, actor: OrgServiceActor) => {
|
||||||
|
const appConnection = await getAppConnection(AppConnection.Heroku, connectionId, actor);
|
||||||
|
try {
|
||||||
|
const apps = await getHerokuApps({ appConnection, appConnectionDAL, kmsService });
|
||||||
|
return apps;
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error, `Failed to establish connection with Heroku for app ${connectionId}`);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
listApps
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import z from "zod";
|
||||||
|
|
||||||
|
import { DiscriminativePick } from "@app/lib/types";
|
||||||
|
|
||||||
|
import { AppConnection } from "../app-connection-enums";
|
||||||
|
import {
|
||||||
|
CreateHerokuConnectionSchema,
|
||||||
|
HerokuConnectionSchema,
|
||||||
|
ValidateHerokuConnectionCredentialsSchema
|
||||||
|
} from "./heroku-connection-schemas";
|
||||||
|
|
||||||
|
export type THerokuConnection = z.infer<typeof HerokuConnectionSchema>;
|
||||||
|
|
||||||
|
export type THerokuConnectionInput = z.infer<typeof CreateHerokuConnectionSchema> & {
|
||||||
|
app: AppConnection.Heroku;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TValidateHerokuConnectionCredentialsSchema = typeof ValidateHerokuConnectionCredentialsSchema;
|
||||||
|
|
||||||
|
export type THerokuConnectionConfig = DiscriminativePick<THerokuConnectionInput, "method" | "app" | "credentials"> & {
|
||||||
|
orgId: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type THerokuApp = {
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export * from "./heroku-connection-enums";
|
||||||
|
export * from "./heroku-connection-fns";
|
||||||
|
export * from "./heroku-connection-schemas";
|
||||||
|
export * from "./heroku-connection-types";
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
|
import { TSecretSyncListItem } from "@app/services/secret-sync/secret-sync-types";
|
||||||
|
|
||||||
|
export const HEROKU_SYNC_LIST_OPTION: TSecretSyncListItem = {
|
||||||
|
name: "Heroku",
|
||||||
|
destination: SecretSync.Heroku,
|
||||||
|
connection: AppConnection.Heroku,
|
||||||
|
canImportSecrets: true
|
||||||
|
};
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
import { request } from "@app/lib/config/request";
|
||||||
|
import { TAppConnectionDALFactory } from "@app/services/app-connection/app-connection-dal";
|
||||||
|
import { HerokuConnectionMethod, refreshHerokuToken, THerokuConnection } from "@app/services/app-connection/heroku";
|
||||||
|
import { IntegrationUrls } from "@app/services/integration-auth/integration-list";
|
||||||
|
import { TKmsServiceFactory } from "@app/services/kms/kms-service";
|
||||||
|
import {
|
||||||
|
THerokuConfigVars,
|
||||||
|
THerokuListVariables,
|
||||||
|
THerokuSyncWithCredentials,
|
||||||
|
THerokuUpdateVariables
|
||||||
|
} from "@app/services/secret-sync/heroku/heroku-sync-types";
|
||||||
|
import { SecretSyncError } from "@app/services/secret-sync/secret-sync-errors";
|
||||||
|
import { matchesSchema } from "@app/services/secret-sync/secret-sync-fns";
|
||||||
|
import { TSecretMap } from "@app/services/secret-sync/secret-sync-types";
|
||||||
|
|
||||||
|
type THerokuSyncFactoryDeps = {
|
||||||
|
appConnectionDAL: Pick<TAppConnectionDALFactory, "updateById">;
|
||||||
|
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getValidAuthToken = async (
|
||||||
|
connection: THerokuConnection,
|
||||||
|
appConnectionDAL: Pick<TAppConnectionDALFactory, "updateById">,
|
||||||
|
kmsService: Pick<TKmsServiceFactory, "createCipherPairWithDataKey">
|
||||||
|
): Promise<string> => {
|
||||||
|
if (
|
||||||
|
connection.method === HerokuConnectionMethod.OAuth &&
|
||||||
|
connection.credentials.refreshToken &&
|
||||||
|
connection.credentials.expiresAt < new Date()
|
||||||
|
) {
|
||||||
|
const authToken = await refreshHerokuToken(
|
||||||
|
connection.credentials.refreshToken,
|
||||||
|
connection.id,
|
||||||
|
connection.orgId,
|
||||||
|
appConnectionDAL,
|
||||||
|
kmsService
|
||||||
|
);
|
||||||
|
return authToken;
|
||||||
|
}
|
||||||
|
return connection.credentials.authToken;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getHerokuConfigVars = async ({ authToken, app }: THerokuListVariables): Promise<THerokuConfigVars> => {
|
||||||
|
const { data } = await request.get<THerokuConfigVars>(
|
||||||
|
`${IntegrationUrls.HEROKU_API_URL}/apps/${encodeURIComponent(app)}/config-vars`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${authToken}`,
|
||||||
|
Accept: "application/vnd.heroku+json; version=3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateHerokuConfigVars = async ({ authToken, app, configVars }: THerokuUpdateVariables) => {
|
||||||
|
return request.patch(`${IntegrationUrls.HEROKU_API_URL}/apps/${encodeURIComponent(app)}/config-vars`, configVars, {
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${authToken}`,
|
||||||
|
Accept: "application/vnd.heroku+json; version=3",
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const HerokuSyncFns = {
|
||||||
|
syncSecrets: async (
|
||||||
|
secretSync: THerokuSyncWithCredentials,
|
||||||
|
secretMap: TSecretMap,
|
||||||
|
{ appConnectionDAL, kmsService }: THerokuSyncFactoryDeps
|
||||||
|
) => {
|
||||||
|
const {
|
||||||
|
connection,
|
||||||
|
environment,
|
||||||
|
destinationConfig: { app }
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
const authToken = await getValidAuthToken(connection, appConnectionDAL, kmsService);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const updatedConfigVars: THerokuConfigVars = {};
|
||||||
|
|
||||||
|
for (const [key, { value }] of Object.entries(secretMap)) {
|
||||||
|
updatedConfigVars[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!secretSync.syncOptions.disableSecretDeletion) {
|
||||||
|
const currentConfigVars = await getHerokuConfigVars({ authToken, app });
|
||||||
|
|
||||||
|
for (const key of Object.keys(currentConfigVars)) {
|
||||||
|
if (matchesSchema(key, environment?.slug || "", secretSync.syncOptions.keySchema) && !(key in secretMap)) {
|
||||||
|
updatedConfigVars[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await updateHerokuConfigVars({
|
||||||
|
authToken,
|
||||||
|
app,
|
||||||
|
configVars: updatedConfigVars
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
throw new SecretSyncError({
|
||||||
|
error,
|
||||||
|
secretKey: "batch_update"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
removeSecrets: async (
|
||||||
|
secretSync: THerokuSyncWithCredentials,
|
||||||
|
secretMap: TSecretMap,
|
||||||
|
{ appConnectionDAL, kmsService }: THerokuSyncFactoryDeps
|
||||||
|
) => {
|
||||||
|
const {
|
||||||
|
connection,
|
||||||
|
destinationConfig: { app }
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
const authToken = await getValidAuthToken(connection, appConnectionDAL, kmsService);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const currentConfigVars = await getHerokuConfigVars({ authToken, app });
|
||||||
|
const configVarsToUpdate: Record<string, null> = {};
|
||||||
|
|
||||||
|
for (const key of Object.keys(secretMap)) {
|
||||||
|
if (key in currentConfigVars) {
|
||||||
|
configVarsToUpdate[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Object.keys(configVarsToUpdate).length > 0) {
|
||||||
|
await updateHerokuConfigVars({
|
||||||
|
authToken,
|
||||||
|
app,
|
||||||
|
configVars: configVarsToUpdate
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
throw new SecretSyncError({
|
||||||
|
error,
|
||||||
|
secretKey: "batch_remove"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getSecrets: async (
|
||||||
|
secretSync: THerokuSyncWithCredentials,
|
||||||
|
{ appConnectionDAL, kmsService }: THerokuSyncFactoryDeps
|
||||||
|
): Promise<TSecretMap> => {
|
||||||
|
const {
|
||||||
|
connection,
|
||||||
|
destinationConfig: { app }
|
||||||
|
} = secretSync;
|
||||||
|
|
||||||
|
const authToken = await getValidAuthToken(connection, appConnectionDAL, kmsService);
|
||||||
|
|
||||||
|
const data = await getHerokuConfigVars({ authToken, app });
|
||||||
|
const transformed = Object.entries(data).reduce((acc, [key, value]) => {
|
||||||
|
if (!value) {
|
||||||
|
return acc;
|
||||||
|
}
|
||||||
|
acc[key] = { value };
|
||||||
|
return acc;
|
||||||
|
}, {} as TSecretMap);
|
||||||
|
|
||||||
|
return transformed;
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { SecretSyncs } from "@app/lib/api-docs";
|
||||||
|
import { AppConnection } from "@app/services/app-connection/app-connection-enums";
|
||||||
|
import { SecretSync } from "@app/services/secret-sync/secret-sync-enums";
|
||||||
|
import {
|
||||||
|
BaseSecretSyncSchema,
|
||||||
|
GenericCreateSecretSyncFieldsSchema,
|
||||||
|
GenericUpdateSecretSyncFieldsSchema
|
||||||
|
} from "@app/services/secret-sync/secret-sync-schemas";
|
||||||
|
import { TSyncOptionsConfig } from "@app/services/secret-sync/secret-sync-types";
|
||||||
|
|
||||||
|
const HerokuSyncDestinationConfigSchema = z.object({
|
||||||
|
app: z.string().trim().min(1, "App required").describe(SecretSyncs.DESTINATION_CONFIG.HEROKU.app),
|
||||||
|
appName: z.string().trim().min(1, "App name required").describe(SecretSyncs.DESTINATION_CONFIG.HEROKU.appName)
|
||||||
|
});
|
||||||
|
|
||||||
|
const HerokuSyncOptionsConfig: TSyncOptionsConfig = { canImportSecrets: true };
|
||||||
|
|
||||||
|
export const HerokuSyncSchema = BaseSecretSyncSchema(SecretSync.Heroku, HerokuSyncOptionsConfig).extend({
|
||||||
|
destination: z.literal(SecretSync.Heroku),
|
||||||
|
destinationConfig: HerokuSyncDestinationConfigSchema
|
||||||
|
});
|
||||||
|
|
||||||
|
export const CreateHerokuSyncSchema = GenericCreateSecretSyncFieldsSchema(
|
||||||
|
SecretSync.Heroku,
|
||||||
|
HerokuSyncOptionsConfig
|
||||||
|
).extend({
|
||||||
|
destinationConfig: HerokuSyncDestinationConfigSchema
|
||||||
|
});
|
||||||
|
|
||||||
|
export const UpdateHerokuSyncSchema = GenericUpdateSecretSyncFieldsSchema(
|
||||||
|
SecretSync.Heroku,
|
||||||
|
HerokuSyncOptionsConfig
|
||||||
|
).extend({
|
||||||
|
destinationConfig: HerokuSyncDestinationConfigSchema.optional()
|
||||||
|
});
|
||||||
|
|
||||||
|
export const HerokuSyncListItemSchema = z.object({
|
||||||
|
name: z.literal("Heroku"),
|
||||||
|
connection: z.literal(AppConnection.Heroku),
|
||||||
|
destination: z.literal(SecretSync.Heroku),
|
||||||
|
canImportSecrets: z.literal(true)
|
||||||
|
});
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { THerokuConnection } from "@app/services/app-connection/heroku";
|
||||||
|
|
||||||
|
import { CreateHerokuSyncSchema, HerokuSyncListItemSchema, HerokuSyncSchema } from "./heroku-sync-schemas";
|
||||||
|
|
||||||
|
export type THerokuSync = z.infer<typeof HerokuSyncSchema>;
|
||||||
|
export type THerokuSyncInput = z.infer<typeof CreateHerokuSyncSchema>;
|
||||||
|
export type THerokuSyncListItem = z.infer<typeof HerokuSyncListItemSchema>;
|
||||||
|
|
||||||
|
export type THerokuSyncWithCredentials = THerokuSync & {
|
||||||
|
connection: THerokuConnection;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type THerokuConfigVars = Record<string, string | null>;
|
||||||
|
|
||||||
|
export type THerokuListVariables = {
|
||||||
|
authToken: string;
|
||||||
|
app: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type THerokuUpdateVariables = THerokuListVariables & {
|
||||||
|
configVars: THerokuConfigVars;
|
||||||
|
};
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export * from "./heroku-sync-constants";
|
||||||
|
export * from "./heroku-sync-fns";
|
||||||
|
export * from "./heroku-sync-schemas";
|
||||||
|
export * from "./heroku-sync-types";
|
||||||
@@ -16,6 +16,7 @@ export enum SecretSync {
|
|||||||
TeamCity = "teamcity",
|
TeamCity = "teamcity",
|
||||||
OCIVault = "oci-vault",
|
OCIVault = "oci-vault",
|
||||||
OnePass = "1password",
|
OnePass = "1password",
|
||||||
|
Heroku = "heroku",
|
||||||
Render = "render",
|
Render = "render",
|
||||||
Flyio = "flyio",
|
Flyio = "flyio",
|
||||||
CloudflarePages = "cloudflare-pages"
|
CloudflarePages = "cloudflare-pages"
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import { FLYIO_SYNC_LIST_OPTION, FlyioSyncFns } from "./flyio";
|
|||||||
import { GCP_SYNC_LIST_OPTION } from "./gcp";
|
import { GCP_SYNC_LIST_OPTION } from "./gcp";
|
||||||
import { GcpSyncFns } from "./gcp/gcp-sync-fns";
|
import { GcpSyncFns } from "./gcp/gcp-sync-fns";
|
||||||
import { HC_VAULT_SYNC_LIST_OPTION, HCVaultSyncFns } from "./hc-vault";
|
import { HC_VAULT_SYNC_LIST_OPTION, HCVaultSyncFns } from "./hc-vault";
|
||||||
|
import { HEROKU_SYNC_LIST_OPTION, HerokuSyncFns } from "./heroku";
|
||||||
import { HUMANITEC_SYNC_LIST_OPTION } from "./humanitec";
|
import { HUMANITEC_SYNC_LIST_OPTION } from "./humanitec";
|
||||||
import { HumanitecSyncFns } from "./humanitec/humanitec-sync-fns";
|
import { HumanitecSyncFns } from "./humanitec/humanitec-sync-fns";
|
||||||
import { RENDER_SYNC_LIST_OPTION, RenderSyncFns } from "./render";
|
import { RENDER_SYNC_LIST_OPTION, RenderSyncFns } from "./render";
|
||||||
@@ -62,6 +63,7 @@ const SECRET_SYNC_LIST_OPTIONS: Record<SecretSync, TSecretSyncListItem> = {
|
|||||||
[SecretSync.TeamCity]: TEAMCITY_SYNC_LIST_OPTION,
|
[SecretSync.TeamCity]: TEAMCITY_SYNC_LIST_OPTION,
|
||||||
[SecretSync.OCIVault]: OCI_VAULT_SYNC_LIST_OPTION,
|
[SecretSync.OCIVault]: OCI_VAULT_SYNC_LIST_OPTION,
|
||||||
[SecretSync.OnePass]: ONEPASS_SYNC_LIST_OPTION,
|
[SecretSync.OnePass]: ONEPASS_SYNC_LIST_OPTION,
|
||||||
|
[SecretSync.Heroku]: HEROKU_SYNC_LIST_OPTION,
|
||||||
[SecretSync.Render]: RENDER_SYNC_LIST_OPTION,
|
[SecretSync.Render]: RENDER_SYNC_LIST_OPTION,
|
||||||
[SecretSync.Flyio]: FLYIO_SYNC_LIST_OPTION,
|
[SecretSync.Flyio]: FLYIO_SYNC_LIST_OPTION,
|
||||||
[SecretSync.CloudflarePages]: CLOUDFLARE_PAGES_SYNC_LIST_OPTION
|
[SecretSync.CloudflarePages]: CLOUDFLARE_PAGES_SYNC_LIST_OPTION
|
||||||
@@ -210,6 +212,8 @@ export const SecretSyncFns = {
|
|||||||
appConnectionDAL,
|
appConnectionDAL,
|
||||||
kmsService
|
kmsService
|
||||||
}).syncSecrets(secretSync, schemaSecretMap);
|
}).syncSecrets(secretSync, schemaSecretMap);
|
||||||
|
case SecretSync.Heroku:
|
||||||
|
return HerokuSyncFns.syncSecrets(secretSync, schemaSecretMap, { appConnectionDAL, kmsService });
|
||||||
case SecretSync.Vercel:
|
case SecretSync.Vercel:
|
||||||
return VercelSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
return VercelSyncFns.syncSecrets(secretSync, schemaSecretMap);
|
||||||
case SecretSync.Windmill:
|
case SecretSync.Windmill:
|
||||||
@@ -305,6 +309,9 @@ export const SecretSyncFns = {
|
|||||||
case SecretSync.OnePass:
|
case SecretSync.OnePass:
|
||||||
secretMap = await OnePassSyncFns.getSecrets(secretSync);
|
secretMap = await OnePassSyncFns.getSecrets(secretSync);
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.Heroku:
|
||||||
|
secretMap = await HerokuSyncFns.getSecrets(secretSync, { appConnectionDAL, kmsService });
|
||||||
|
break;
|
||||||
case SecretSync.Render:
|
case SecretSync.Render:
|
||||||
secretMap = await RenderSyncFns.getSecrets(secretSync);
|
secretMap = await RenderSyncFns.getSecrets(secretSync);
|
||||||
break;
|
break;
|
||||||
@@ -381,6 +388,8 @@ export const SecretSyncFns = {
|
|||||||
return OCIVaultSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
return OCIVaultSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
||||||
case SecretSync.OnePass:
|
case SecretSync.OnePass:
|
||||||
return OnePassSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
return OnePassSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
||||||
|
case SecretSync.Heroku:
|
||||||
|
return HerokuSyncFns.removeSecrets(secretSync, schemaSecretMap, { appConnectionDAL, kmsService });
|
||||||
case SecretSync.Render:
|
case SecretSync.Render:
|
||||||
return RenderSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
return RenderSyncFns.removeSecrets(secretSync, schemaSecretMap);
|
||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export const SECRET_SYNC_NAME_MAP: Record<SecretSync, string> = {
|
|||||||
[SecretSync.TeamCity]: "TeamCity",
|
[SecretSync.TeamCity]: "TeamCity",
|
||||||
[SecretSync.OCIVault]: "OCI Vault",
|
[SecretSync.OCIVault]: "OCI Vault",
|
||||||
[SecretSync.OnePass]: "1Password",
|
[SecretSync.OnePass]: "1Password",
|
||||||
|
[SecretSync.Heroku]: "Heroku",
|
||||||
[SecretSync.Render]: "Render",
|
[SecretSync.Render]: "Render",
|
||||||
[SecretSync.Flyio]: "Fly.io",
|
[SecretSync.Flyio]: "Fly.io",
|
||||||
[SecretSync.CloudflarePages]: "Cloudflare Pages"
|
[SecretSync.CloudflarePages]: "Cloudflare Pages"
|
||||||
@@ -42,6 +43,7 @@ export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
|||||||
[SecretSync.TeamCity]: AppConnection.TeamCity,
|
[SecretSync.TeamCity]: AppConnection.TeamCity,
|
||||||
[SecretSync.OCIVault]: AppConnection.OCI,
|
[SecretSync.OCIVault]: AppConnection.OCI,
|
||||||
[SecretSync.OnePass]: AppConnection.OnePass,
|
[SecretSync.OnePass]: AppConnection.OnePass,
|
||||||
|
[SecretSync.Heroku]: AppConnection.Heroku,
|
||||||
[SecretSync.Render]: AppConnection.Render,
|
[SecretSync.Render]: AppConnection.Render,
|
||||||
[SecretSync.Flyio]: AppConnection.Flyio,
|
[SecretSync.Flyio]: AppConnection.Flyio,
|
||||||
[SecretSync.CloudflarePages]: AppConnection.Cloudflare
|
[SecretSync.CloudflarePages]: AppConnection.Cloudflare
|
||||||
@@ -65,6 +67,7 @@ export const SECRET_SYNC_PLAN_MAP: Record<SecretSync, SecretSyncPlanType> = {
|
|||||||
[SecretSync.TeamCity]: SecretSyncPlanType.Regular,
|
[SecretSync.TeamCity]: SecretSyncPlanType.Regular,
|
||||||
[SecretSync.OCIVault]: SecretSyncPlanType.Enterprise,
|
[SecretSync.OCIVault]: SecretSyncPlanType.Enterprise,
|
||||||
[SecretSync.OnePass]: SecretSyncPlanType.Regular,
|
[SecretSync.OnePass]: SecretSyncPlanType.Regular,
|
||||||
|
[SecretSync.Heroku]: SecretSyncPlanType.Regular,
|
||||||
[SecretSync.Render]: SecretSyncPlanType.Regular,
|
[SecretSync.Render]: SecretSyncPlanType.Regular,
|
||||||
[SecretSync.Flyio]: SecretSyncPlanType.Regular,
|
[SecretSync.Flyio]: SecretSyncPlanType.Regular,
|
||||||
[SecretSync.CloudflarePages]: SecretSyncPlanType.Regular
|
[SecretSync.CloudflarePages]: SecretSyncPlanType.Regular
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ import {
|
|||||||
THCVaultSyncListItem,
|
THCVaultSyncListItem,
|
||||||
THCVaultSyncWithCredentials
|
THCVaultSyncWithCredentials
|
||||||
} from "./hc-vault/hc-vault-sync-types";
|
} from "./hc-vault/hc-vault-sync-types";
|
||||||
|
import { THerokuSync, THerokuSyncInput, THerokuSyncListItem, THerokuSyncWithCredentials } from "./heroku";
|
||||||
import {
|
import {
|
||||||
THumanitecSync,
|
THumanitecSync,
|
||||||
THumanitecSyncInput,
|
THumanitecSyncInput,
|
||||||
@@ -130,6 +131,7 @@ export type TSecretSync =
|
|||||||
| TTeamCitySync
|
| TTeamCitySync
|
||||||
| TOCIVaultSync
|
| TOCIVaultSync
|
||||||
| TOnePassSync
|
| TOnePassSync
|
||||||
|
| THerokuSync
|
||||||
| TRenderSync
|
| TRenderSync
|
||||||
| TFlyioSync
|
| TFlyioSync
|
||||||
| TCloudflarePagesSync;
|
| TCloudflarePagesSync;
|
||||||
@@ -152,6 +154,7 @@ export type TSecretSyncWithCredentials =
|
|||||||
| TTeamCitySyncWithCredentials
|
| TTeamCitySyncWithCredentials
|
||||||
| TOCIVaultSyncWithCredentials
|
| TOCIVaultSyncWithCredentials
|
||||||
| TOnePassSyncWithCredentials
|
| TOnePassSyncWithCredentials
|
||||||
|
| THerokuSyncWithCredentials
|
||||||
| TRenderSyncWithCredentials
|
| TRenderSyncWithCredentials
|
||||||
| TFlyioSyncWithCredentials
|
| TFlyioSyncWithCredentials
|
||||||
| TCloudflarePagesSyncWithCredentials;
|
| TCloudflarePagesSyncWithCredentials;
|
||||||
@@ -174,6 +177,7 @@ export type TSecretSyncInput =
|
|||||||
| TTeamCitySyncInput
|
| TTeamCitySyncInput
|
||||||
| TOCIVaultSyncInput
|
| TOCIVaultSyncInput
|
||||||
| TOnePassSyncInput
|
| TOnePassSyncInput
|
||||||
|
| THerokuSyncInput
|
||||||
| TRenderSyncInput
|
| TRenderSyncInput
|
||||||
| TFlyioSyncInput
|
| TFlyioSyncInput
|
||||||
| TCloudflarePagesSyncInput;
|
| TCloudflarePagesSyncInput;
|
||||||
@@ -196,6 +200,7 @@ export type TSecretSyncListItem =
|
|||||||
| TTeamCitySyncListItem
|
| TTeamCitySyncListItem
|
||||||
| TOCIVaultSyncListItem
|
| TOCIVaultSyncListItem
|
||||||
| TOnePassSyncListItem
|
| TOnePassSyncListItem
|
||||||
|
| THerokuSyncListItem
|
||||||
| TRenderSyncListItem
|
| TRenderSyncListItem
|
||||||
| TFlyioSyncListItem
|
| TFlyioSyncListItem
|
||||||
| TCloudflarePagesSyncListItem;
|
| TCloudflarePagesSyncListItem;
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Available"
|
||||||
|
openapi: "GET /api/v1/app-connections/heroku/available"
|
||||||
|
---
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "Create"
|
||||||
|
openapi: "POST /api/v1/app-connections/heroku"
|
||||||
|
---
|
||||||
|
|
||||||
|
<Note>
|
||||||
|
Heroku OAuth Connections must be created through the Infisical UI.
|
||||||
|
Check out the configuration docs for [Heroku OAuth Connections](/integrations/app-connections/heroku) for a step-by-step
|
||||||
|
guide.
|
||||||
|
</Note>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Delete"
|
||||||
|
openapi: "DELETE /api/v1/app-connections/heroku/{connectionId}"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Get by ID"
|
||||||
|
openapi: "GET /api/v1/app-connections/heroku/{connectionId}"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Get by Name"
|
||||||
|
openapi: "GET /api/v1/app-connections/heroku/connection-name/{connectionName}"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "List"
|
||||||
|
openapi: "GET /api/v1/app-connections/heroku"
|
||||||
|
---
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "Update"
|
||||||
|
openapi: "PATCH /api/v1/app-connections/heroku/{connectionId}"
|
||||||
|
---
|
||||||
|
|
||||||
|
<Note>
|
||||||
|
Heroku OAuth Connections must be updated through the Infisical UI.
|
||||||
|
Check out the configuration docs for [Heroku OAuth Connections](/integrations/app-connections/heroku) for a step-by-step
|
||||||
|
guide.
|
||||||
|
</Note>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Create"
|
||||||
|
openapi: "POST /api/v1/secret-syncs/heroku"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Delete"
|
||||||
|
openapi: "DELETE /api/v1/secret-syncs/heroku/{syncId}"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Get by ID"
|
||||||
|
openapi: "GET /api/v1/secret-syncs/heroku/{syncId}"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Get by Name"
|
||||||
|
openapi: "GET /api/v1/secret-syncs/heroku/sync-name/{syncName}"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Import Secrets"
|
||||||
|
openapi: "POST /api/v1/secret-syncs/heroku/{syncId}/import-secrets"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "List"
|
||||||
|
openapi: "GET /api/v1/secret-syncs/heroku"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Remove Secrets"
|
||||||
|
openapi: "POST /api/v1/secret-syncs/heroku/{syncId}/remove-secrets"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Sync Secrets"
|
||||||
|
openapi: "POST /api/v1/secret-syncs/heroku/{syncId}/sync-secrets"
|
||||||
|
---
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
title: "Update"
|
||||||
|
openapi: "PATCH /api/v1/secret-syncs/heroku/{syncId}"
|
||||||
|
---
|
||||||
@@ -127,8 +127,8 @@ Follow the instructions for your operating system to install the Infisical CLI.
|
|||||||
|
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab title="Debian/Ubuntu">
|
<Tab title="Debian/Ubuntu">
|
||||||
Add Infisical repository
|
Add Infisical repository
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ curl -1sLf \
|
$ curl -1sLf \
|
||||||
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.deb.sh' \
|
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.deb.sh' \
|
||||||
@@ -143,7 +143,7 @@ Follow the instructions for your operating system to install the Infisical CLI.
|
|||||||
</Tab>
|
</Tab>
|
||||||
<Tab title="Arch Linux">
|
<Tab title="Arch Linux">
|
||||||
Use the `yay` package manager to install from the [Arch User Repository](https://aur.archlinux.org/packages/infisical-bin)
|
Use the `yay` package manager to install from the [Arch User Repository](https://aur.archlinux.org/packages/infisical-bin)
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ yay -S infisical-bin
|
$ yay -S infisical-bin
|
||||||
```
|
```
|
||||||
@@ -187,7 +187,7 @@ We'll now use the Infisical-Vercel integration send secrets from Infisical to Ve
|
|||||||
|
|
||||||
### Infisical-Vercel integration
|
### Infisical-Vercel integration
|
||||||
|
|
||||||
To begin we have to import the Next.js app into Vercel as a project. [Follow these instructions](https://nextjs.org/learn/basics/deploying-nextjs-app/deploy) to deploy the Next.js app to Vercel.
|
To begin we have to import the Next.js app into Vercel as a project. [Follow these instructions](https://vercel.com/docs/frameworks/nextjs) to deploy the Next.js app to Vercel.
|
||||||
|
|
||||||
Next, navigate to your project's integrations tab in Infisical and press on the Vercel tile to grant Infisical access to your Vercel account.
|
Next, navigate to your project's integrations tab in Infisical and press on the Vercel tile to grant Infisical access to your Vercel account.
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ At this stage, you know how to use the Infisical-Vercel integration to sync prod
|
|||||||
</Accordion>
|
</Accordion>
|
||||||
<Accordion title="Is opting out of end-to-end encryption for the Infisical-Vercel integration safe?">
|
<Accordion title="Is opting out of end-to-end encryption for the Infisical-Vercel integration safe?">
|
||||||
Yes. Your secrets are still encrypted at rest. To note, most secret managers actually don't support end-to-end encryption.
|
Yes. Your secrets are still encrypted at rest. To note, most secret managers actually don't support end-to-end encryption.
|
||||||
|
|
||||||
Check out the [security guide](/security/overview).
|
Check out the [security guide](/security/overview).
|
||||||
</Accordion>
|
</Accordion>
|
||||||
</AccordionGroup>
|
</AccordionGroup>
|
||||||
|
|||||||
@@ -161,6 +161,11 @@ Replace **\<account id\>** with your AWS account id and **\<aws-scope-path\>** w
|
|||||||
{{replace identity.name 'user' 'replace'}} // testreplace
|
{{replace identity.name 'user' 'replace'}} // testreplace
|
||||||
```
|
```
|
||||||
</ParamField>
|
</ParamField>
|
||||||
|
|
||||||
|
<ParamField path="Tags" type="map<string, string>[]">
|
||||||
|
Tags to be added to the created IAM User resource.
|
||||||
|
</ParamField>
|
||||||
|
|
||||||
<ParamField path="Method" type="string" required>
|
<ParamField path="Method" type="string" required>
|
||||||
Select *Assume Role* method.
|
Select *Assume Role* method.
|
||||||
</ParamField>
|
</ParamField>
|
||||||
@@ -304,6 +309,10 @@ Replace **\<account id\>** with your AWS account id and **\<aws-scope-path\>** w
|
|||||||
- `{{unixTimestamp}}`: Current Unix timestamp
|
- `{{unixTimestamp}}`: Current Unix timestamp
|
||||||
</ParamField>
|
</ParamField>
|
||||||
|
|
||||||
|
<ParamField path="Tags" type="map[string]string">
|
||||||
|
Tags to be added to the created IAM User resource.
|
||||||
|
</ParamField>
|
||||||
|
|
||||||
</Step>
|
</Step>
|
||||||
|
|
||||||
<Step title="Click 'Submit'">
|
<Step title="Click 'Submit'">
|
||||||
|
|||||||
@@ -0,0 +1,112 @@
|
|||||||
|
---
|
||||||
|
title: "GitHub"
|
||||||
|
description: "Learn how to dynamically generate GitHub App tokens."
|
||||||
|
---
|
||||||
|
|
||||||
|
The Infisical GitHub dynamic secret allows you to generate short-lived tokens for a GitHub App on demand based on service account permissions.
|
||||||
|
|
||||||
|
## Setup GitHub App
|
||||||
|
|
||||||
|
<Steps>
|
||||||
|
<Step title="Create an application on GitHub">
|
||||||
|
Navigate to [GitHub App settings](https://github.com/settings/apps) and click **New GitHub App**.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Give the application a name and a homepage URL. These values do not need to be anything specific.
|
||||||
|
|
||||||
|
Disable webhook by unchecking the Active checkbox.
|
||||||
|

|
||||||
|
|
||||||
|
Configure the app's permissions to grant the necessary access for the dynamic secret's short-lived tokens based on your use case.
|
||||||
|
|
||||||
|
Create the GitHub Application.
|
||||||
|

|
||||||
|
|
||||||
|
<Note>
|
||||||
|
If you have a GitHub organization, you can create an application under it
|
||||||
|
in your organization Settings > Developer settings > GitHub Apps > New GitHub App.
|
||||||
|
</Note>
|
||||||
|
</Step>
|
||||||
|
<Step title="Save app credentials">
|
||||||
|
Copy the **App ID** and generate a new **Private Key** for your GitHub Application.
|
||||||
|

|
||||||
|
|
||||||
|
Save these for later steps.
|
||||||
|
</Step>
|
||||||
|
<Step title="Install app">
|
||||||
|
Install your application to whichever repositories and organizations that you want the dynamic secret to access.
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Once you've installed the app, **copy the installation ID** from the URL and save it for later steps.
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
</Steps>
|
||||||
|
|
||||||
|
## Set up Dynamic Secrets with GitHub
|
||||||
|
|
||||||
|
<Steps>
|
||||||
|
<Step title="Open Secret Overview Dashboard">
|
||||||
|
Open the Secret Overview dashboard and select the environment in which you would like to add a dynamic secret.
|
||||||
|
</Step>
|
||||||
|
<Step title="Click on the 'Add Dynamic Secret' button">
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Select 'GitHub'">
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Provide the inputs for dynamic secret parameters">
|
||||||
|
<ParamField path="Secret Name" type="string" required>
|
||||||
|
Name by which you want the secret to be referenced
|
||||||
|
</ParamField>
|
||||||
|
<ParamField path="App ID" type="string" required>
|
||||||
|
The ID of the app created in earlier steps.
|
||||||
|
</ParamField>
|
||||||
|
<ParamField path="App Private Key PEM" type="string" required>
|
||||||
|
The Private Key of the app created in earlier steps.
|
||||||
|
</ParamField>
|
||||||
|
<ParamField path="Installation ID" type="string" required>
|
||||||
|
The ID of the installation from earlier steps.
|
||||||
|
</ParamField>
|
||||||
|
</Step>
|
||||||
|
<Step title="Click `Submit`">
|
||||||
|
After submitting the form, you will see a dynamic secret created in the dashboard.
|
||||||
|
</Step>
|
||||||
|
|
||||||
|
<Step title="Generate dynamic secrets">
|
||||||
|
Once you've successfully configured the dynamic secret, you're ready to generate on-demand credentials.
|
||||||
|
To do this, simply click on the 'Generate' button which appears when hovering over the dynamic secret item.
|
||||||
|
Alternatively, you can initiate the creation of a new lease by selecting 'New Lease' from the dynamic secret lease list section.
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
When generating these secrets, the TTL will be fixed to 1 hour.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Once you click the `Submit` button, a new secret lease will be generated and the credentials from it will be shown to you.
|
||||||
|
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
</Steps>
|
||||||
|
|
||||||
|
## Audit or Revoke Leases
|
||||||
|
|
||||||
|
Once you have created one or more leases, you will be able to access them by clicking on the respective dynamic secret item on the dashboard.
|
||||||
|
|
||||||
|
This will allow you to see the expiration time of the lease or delete a lease before its set time to live.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
<Warning>
|
||||||
|
GitHub App tokens cannot be revoked. As such, revoking a token on Infisical does not invalidate the GitHub token; it remains active until it expires.
|
||||||
|
</Warning>
|
||||||
|
|
||||||
|
## Renew Leases
|
||||||
|
|
||||||
|
<Note>
|
||||||
|
GitHub App tokens cannot be renewed because they are fixed to a lifetime of 1 hour.
|
||||||
|
</Note>
|
||||||
@@ -49,11 +49,21 @@ In the following steps, we explore how to install the Infisical PKI Issuer using
|
|||||||
```
|
```
|
||||||
</Step>
|
</Step>
|
||||||
<Step title="Install the Issuer Controller">
|
<Step title="Install the Issuer Controller">
|
||||||
Install the Infisical PKI Issuer controller into your Kubernetes cluster by running the following command:
|
Install the Infisical PKI Issuer controller into your Kubernetes cluster using one of the following methods:
|
||||||
|
|
||||||
```bash
|
<Tabs>
|
||||||
kubectl apply -f https://raw.githubusercontent.com/Infisical/infisical-issuer/main/build/install.yaml
|
<Tab title="Helm">
|
||||||
```
|
```bash
|
||||||
|
helm repo add infisical-helm-charts 'https://dl.cloudsmith.io/public/infisical/helm-charts/helm/charts/'
|
||||||
|
helm install infisical-pki-issuer infisical-helm-charts/infisical-pki-issuer
|
||||||
|
```
|
||||||
|
</Tab>
|
||||||
|
<Tab title="kubectl">
|
||||||
|
```bash
|
||||||
|
kubectl apply -f https://raw.githubusercontent.com/Infisical/infisical-issuer/main/build/install.yaml
|
||||||
|
```
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
</Step>
|
</Step>
|
||||||
<Step title="Create Kubernetes Secret for Infisical PKI Issuer">
|
<Step title="Create Kubernetes Secret for Infisical PKI Issuer">
|
||||||
Start by creating a Kubernetes `Secret` containing the **Client Secret** from step 1. As mentioned previously, this will be used by the Infisical PKI issuer to authenticate with Infisical.
|
Start by creating a Kubernetes `Secret` containing the **Client Secret** from step 1. As mentioned previously, this will be used by the Infisical PKI issuer to authenticate with Infisical.
|
||||||
|
|||||||
|
After Width: | Height: | Size: 392 KiB |
|
After Width: | Height: | Size: 988 KiB |
|
After Width: | Height: | Size: 609 KiB |
|
After Width: | Height: | Size: 618 KiB |
|
After Width: | Height: | Size: 733 KiB |
|
After Width: | Height: | Size: 147 KiB |
|
After Width: | Height: | Size: 205 KiB |
|
After Width: | Height: | Size: 518 KiB |
|
After Width: | Height: | Size: 47 KiB |
|
After Width: | Height: | Size: 145 KiB |
|
After Width: | Height: | Size: 1014 KiB |
|
After Width: | Height: | Size: 610 KiB |
|
After Width: | Height: | Size: 599 KiB |
|
After Width: | Height: | Size: 640 KiB |
|
After Width: | Height: | Size: 631 KiB |
|
After Width: | Height: | Size: 591 KiB |
|
After Width: | Height: | Size: 677 KiB |
@@ -0,0 +1,121 @@
|
|||||||
|
---
|
||||||
|
title: "Heroku App Connection"
|
||||||
|
description: "Learn how to configure a Heroku App Connection for Infisical using OAuth or Auth Token methods."
|
||||||
|
---
|
||||||
|
|
||||||
|
Infisical supports two methods for connecting to Heroku: **OAuth** and **Auth Token**. Choose the method that best fits your setup and security requirements.
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<Tab title="OAuth Method">
|
||||||
|
The OAuth method provides secure authentication through Heroku's OAuth flow.
|
||||||
|
|
||||||
|
<Accordion title="Self-Hosted Instance Setup">
|
||||||
|
Using the Heroku App Connection with OAuth on a self-hosted instance of Infisical requires configuring an API client in Heroku and registering your instance with it.
|
||||||
|
|
||||||
|
**Prerequisites:**
|
||||||
|
- A Heroku account with existing applications
|
||||||
|
- Self-hosted Infisical instance
|
||||||
|
|
||||||
|
<Steps>
|
||||||
|
<Step title="Create an API client in Heroku">
|
||||||
|
Navigate to your user Account settings > Applications to create a new API client.
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
Create the API client. As part of the form, set the **OAuth callback URL** to `https://your-domain.com/integrations/heroku/oauth2/callback`.
|
||||||
|
|
||||||
|
<Tip>
|
||||||
|
The domain you defined in the OAuth callback URL should be equivalent to the `SITE_URL` configured in your Infisical instance.
|
||||||
|
</Tip>
|
||||||
|
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Add your Heroku API client credentials to Infisical">
|
||||||
|
Obtain the **Client ID** and **Client Secret** for your Heroku API client.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Back in your Infisical instance, add two new environment variables for the credentials of your Heroku API client:
|
||||||
|
|
||||||
|
- `CLIENT_ID_HEROKU`: The **Client ID** of your Heroku API client.
|
||||||
|
- `CLIENT_SECRET_HEROKU`: The **Client Secret** of your Heroku API client.
|
||||||
|
|
||||||
|
Once added, restart your Infisical instance and use the Heroku App Connection.
|
||||||
|
</Step>
|
||||||
|
</Steps>
|
||||||
|
</Accordion>
|
||||||
|
|
||||||
|
## Setup Heroku OAuth Connection in Infisical
|
||||||
|
|
||||||
|
<Steps>
|
||||||
|
<Step title="Navigate to App Connections">
|
||||||
|
Navigate to the **App Connections** tab on the **Organization Settings** page.
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Add Connection">
|
||||||
|
Select the **Heroku App Connection** option from the connection options modal.
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Choose OAuth Method">
|
||||||
|
Select the **OAuth** method and click **Connect to Heroku**.
|
||||||
|
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Grant Access">
|
||||||
|
You will be redirected to Heroku to grant Infisical access to your Heroku account. Once granted, you will be redirected back to Infisical's App Connections page.
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Connection Created">
|
||||||
|
Your **Heroku App Connection** is now available for use.
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
</Steps>
|
||||||
|
|
||||||
|
</Tab>
|
||||||
|
|
||||||
|
<Tab title="Auth Token Method">
|
||||||
|
The Auth Token method uses a Heroku API token for authentication, providing a straightforward setup process.
|
||||||
|
|
||||||
|
## Setup Heroku Auth Token Connection in Infisical
|
||||||
|
|
||||||
|
<Steps>
|
||||||
|
<Step title="Generate Heroku API Token">
|
||||||
|
Log in to your Heroku account and navigate to Account Settings.
|
||||||
|
|
||||||
|
Under the **Authorizations** section on the **Applications** tab, reveal and copy your Authorization token. If you don't have one, click **Create Authorization** to create a new token.
|
||||||
|
|
||||||
|
<Warning>
|
||||||
|
Keep your Authorization token secure and do not share it. Anyone with access to this token can manage your Heroku applications.
|
||||||
|
</Warning>
|
||||||
|
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Navigate to App Connections">
|
||||||
|
Navigate to the **App Connections** tab on the **Organization Settings** page.
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Add Connection">
|
||||||
|
Select the **Heroku App Connection** option from the connection options modal.
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
<Step title="Configure Auth Token">
|
||||||
|
Select the **Auth Token** method and paste your Heroku Authorization token in the provided field.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
Click **Connect** to establish the connection.
|
||||||
|
</Step>
|
||||||
|
<Step title="Connection Created">
|
||||||
|
Your **Heroku App Connection** is now available for use.
|
||||||
|

|
||||||
|
</Step>
|
||||||
|
</Steps>
|
||||||
|
|
||||||
|
<Info>
|
||||||
|
Auth Token connections require manual token rotation when your Heroku Authorization expires or is regenerated. Monitor your connection status and update the token as needed.
|
||||||
|
</Info>
|
||||||
|
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
---
|
||||||
|
title: "Heroku Sync"
|
||||||
|
description: "Learn how to configure a Heroku Sync for Infisical."
|
||||||
|
---
|
||||||
|
|
||||||
|
**Prerequisites:**
|
||||||
|
|
||||||
|
- Set up and add secrets to [Infisical Cloud](https://app.infisical.com)
|
||||||
|
- Create a [Heroku App Connection](/integrations/app-connections/heroku)
|
||||||
|
|
||||||
|
<Tabs>
|
||||||
|
<Tab title="Infisical UI">
|
||||||
|
1. Navigate to **Project** > **Integrations** and select the **Secret Syncs** tab. Click on the **Add Sync** button.
|
||||||
|

|
||||||
|
|
||||||
|
2. Select the **Heroku** option.
|
||||||
|

|
||||||
|
|
||||||
|
3. Configure the **Source** from where secrets should be retrieved, then click **Next**.
|
||||||
|

|
||||||
|
|
||||||
|
- **Environment**: The project environment to retrieve secrets from.
|
||||||
|
- **Secret Path**: The folder path to retrieve secrets from.
|
||||||
|
|
||||||
|
<Tip>
|
||||||
|
If you need to sync secrets from multiple folder locations, check out [secret imports](/documentation/platform/secret-reference#secret-imports).
|
||||||
|
</Tip>
|
||||||
|
|
||||||
|
4. Configure the **Destination** to where secrets should be deployed, then click **Next**.
|
||||||
|

|
||||||
|
|
||||||
|
- **Heroku App Connection**: The Heroku App Connection to authenticate with.
|
||||||
|
- **Heroku App**: The Heroku application to sync secrets to.
|
||||||
|
|
||||||
|
5. Configure the **Sync Options** to specify how secrets should be synced, then click **Next**.
|
||||||
|

|
||||||
|
|
||||||
|
- **Initial Sync Behavior**: Determines how Infisical should resolve the initial sync.
|
||||||
|
- **Import - Prefer values from Infisical**: Import secrets from Heroku to Infisical; if a secret with the same name already exists in Infisical, do nothing. Afterwards, sync secrets to Heroku.
|
||||||
|
- **Import - Prefer values from Heroku**: Import secrets from Heroku to Infisical; if a secret with the same name already exists in Infisical, replace its value with the one from Heroku. Afterwards, sync secrets to Heroku.
|
||||||
|
- **Overwrite Destination Secrets**: Removes any secrets at the destination endpoint not present in Infisical.
|
||||||
|
- **Key Schema**: Template that determines how secret names are transformed when syncing, using `{{secretKey}}` as a placeholder for the original secret name and `{{environment}}` for the environment.
|
||||||
|
<Note>
|
||||||
|
We highly recommend using a Key Schema to ensure that Infisical only manages the specific keys you intend, keeping everything else untouched.
|
||||||
|
</Note>
|
||||||
|
- **Auto-Sync Enabled**: If enabled, secrets will automatically be synced from the source location when changes occur. Disable to enforce manual syncing only.
|
||||||
|
- **Disable Secret Deletion**: If enabled, Infisical will not remove secrets from the sync destination. Enable this option if you intend to manage some secrets manually outside of Infisical.
|
||||||
|
|
||||||
|
6. Configure the **Details** of your Heroku Sync, then click **Next**.
|
||||||
|

|
||||||
|
|
||||||
|
- **Name**: The name of your sync. Must be slug-friendly.
|
||||||
|
- **Description**: An optional description for your sync.
|
||||||
|
|
||||||
|
7. Review your Heroku Sync configuration, then click **Create Sync**.
|
||||||
|

|
||||||
|
|
||||||
|
8. If enabled, your Heroku Sync will begin syncing your secrets to the destination endpoint.
|
||||||
|

|
||||||
|
|
||||||
|
</Tab>
|
||||||
|
<Tab title="API">
|
||||||
|
To create a **Heroku Sync**, make an API request to the [Create Heroku Sync](/api-reference/endpoints/secret-syncs/heroku/create) API endpoint.
|
||||||
|
|
||||||
|
### Sample request
|
||||||
|
|
||||||
|
```bash Request
|
||||||
|
curl --request POST \
|
||||||
|
--url https://app.infisical.com/api/v1/secret-syncs/heroku \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--data '{
|
||||||
|
"name": "my-heroku-sync",
|
||||||
|
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"description": "an example sync",
|
||||||
|
"connectionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"environment": "dev",
|
||||||
|
"secretPath": "/my-secrets",
|
||||||
|
"isEnabled": true,
|
||||||
|
"syncOptions": {
|
||||||
|
"initialSyncBehavior": "overwrite-destination",
|
||||||
|
"disableSecretDeletion": true
|
||||||
|
},
|
||||||
|
"destinationConfig": {
|
||||||
|
"app": "8dd25736052a4b50",
|
||||||
|
"appName": "my-app"
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sample response
|
||||||
|
|
||||||
|
```bash Response
|
||||||
|
{
|
||||||
|
"secretSync": {
|
||||||
|
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"name": "my-heroku-sync",
|
||||||
|
"description": "an example sync",
|
||||||
|
"isEnabled": true,
|
||||||
|
"version": 1,
|
||||||
|
"folderId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"connectionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"createdAt": "2023-11-07T05:31:56Z",
|
||||||
|
"updatedAt": "2023-11-07T05:31:56Z",
|
||||||
|
"syncStatus": "succeeded",
|
||||||
|
"lastSyncJobId": "123",
|
||||||
|
"lastSyncMessage": null,
|
||||||
|
"lastSyncedAt": "2023-11-07T05:31:56Z",
|
||||||
|
"importStatus": null,
|
||||||
|
"lastImportJobId": null,
|
||||||
|
"lastImportMessage": null,
|
||||||
|
"lastImportedAt": null,
|
||||||
|
"removeStatus": null,
|
||||||
|
"lastRemoveJobId": null,
|
||||||
|
"lastRemoveMessage": null,
|
||||||
|
"lastRemovedAt": null,
|
||||||
|
"syncOptions": {
|
||||||
|
"initialSyncBehavior": "overwrite-destination",
|
||||||
|
"disableSecretDeletion": true
|
||||||
|
},
|
||||||
|
"projectId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"connection": {
|
||||||
|
"app": "heroku",
|
||||||
|
"name": "my-heroku-connection",
|
||||||
|
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
"slug": "dev",
|
||||||
|
"name": "Development",
|
||||||
|
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
|
||||||
|
},
|
||||||
|
"folder": {
|
||||||
|
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
|
||||||
|
"path": "/my-secrets"
|
||||||
|
},
|
||||||
|
"destination": "heroku",
|
||||||
|
"destinationConfig": {
|
||||||
|
"app": "8dd25736052a4b50",
|
||||||
|
"appName": "my-app"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
</Tab>
|
||||||
|
</Tabs>
|
||||||
@@ -214,6 +214,7 @@
|
|||||||
"documentation/platform/dynamic-secrets/cassandra",
|
"documentation/platform/dynamic-secrets/cassandra",
|
||||||
"documentation/platform/dynamic-secrets/elastic-search",
|
"documentation/platform/dynamic-secrets/elastic-search",
|
||||||
"documentation/platform/dynamic-secrets/gcp-iam",
|
"documentation/platform/dynamic-secrets/gcp-iam",
|
||||||
|
"documentation/platform/dynamic-secrets/github",
|
||||||
"documentation/platform/dynamic-secrets/ldap",
|
"documentation/platform/dynamic-secrets/ldap",
|
||||||
"documentation/platform/dynamic-secrets/mongo-atlas",
|
"documentation/platform/dynamic-secrets/mongo-atlas",
|
||||||
"documentation/platform/dynamic-secrets/mongo-db",
|
"documentation/platform/dynamic-secrets/mongo-db",
|
||||||
@@ -509,6 +510,7 @@
|
|||||||
"integrations/app-connections/github",
|
"integrations/app-connections/github",
|
||||||
"integrations/app-connections/github-radar",
|
"integrations/app-connections/github-radar",
|
||||||
"integrations/app-connections/hashicorp-vault",
|
"integrations/app-connections/hashicorp-vault",
|
||||||
|
"integrations/app-connections/heroku",
|
||||||
"integrations/app-connections/humanitec",
|
"integrations/app-connections/humanitec",
|
||||||
"integrations/app-connections/ldap",
|
"integrations/app-connections/ldap",
|
||||||
"integrations/app-connections/mssql",
|
"integrations/app-connections/mssql",
|
||||||
@@ -544,6 +546,7 @@
|
|||||||
"integrations/secret-syncs/gcp-secret-manager",
|
"integrations/secret-syncs/gcp-secret-manager",
|
||||||
"integrations/secret-syncs/github",
|
"integrations/secret-syncs/github",
|
||||||
"integrations/secret-syncs/hashicorp-vault",
|
"integrations/secret-syncs/hashicorp-vault",
|
||||||
|
"integrations/secret-syncs/heroku",
|
||||||
"integrations/secret-syncs/humanitec",
|
"integrations/secret-syncs/humanitec",
|
||||||
"integrations/secret-syncs/oci-vault",
|
"integrations/secret-syncs/oci-vault",
|
||||||
"integrations/secret-syncs/render",
|
"integrations/secret-syncs/render",
|
||||||
@@ -1327,6 +1330,18 @@
|
|||||||
"api-reference/endpoints/app-connections/hashicorp-vault/delete"
|
"api-reference/endpoints/app-connections/hashicorp-vault/delete"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"group": "Heroku",
|
||||||
|
"pages": [
|
||||||
|
"api-reference/endpoints/app-connections/heroku/list",
|
||||||
|
"api-reference/endpoints/app-connections/heroku/available",
|
||||||
|
"api-reference/endpoints/app-connections/heroku/get-by-id",
|
||||||
|
"api-reference/endpoints/app-connections/heroku/get-by-name",
|
||||||
|
"api-reference/endpoints/app-connections/heroku/create",
|
||||||
|
"api-reference/endpoints/app-connections/heroku/update",
|
||||||
|
"api-reference/endpoints/app-connections/heroku/delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"group": "Humanitec",
|
"group": "Humanitec",
|
||||||
"pages": [
|
"pages": [
|
||||||
@@ -1642,6 +1657,19 @@
|
|||||||
"api-reference/endpoints/secret-syncs/hashicorp-vault/remove-secrets"
|
"api-reference/endpoints/secret-syncs/hashicorp-vault/remove-secrets"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"group": "Heroku",
|
||||||
|
"pages": [
|
||||||
|
"api-reference/endpoints/secret-syncs/heroku/list",
|
||||||
|
"api-reference/endpoints/secret-syncs/heroku/get-by-id",
|
||||||
|
"api-reference/endpoints/secret-syncs/heroku/get-by-name",
|
||||||
|
"api-reference/endpoints/secret-syncs/heroku/create",
|
||||||
|
"api-reference/endpoints/secret-syncs/heroku/update",
|
||||||
|
"api-reference/endpoints/secret-syncs/heroku/delete",
|
||||||
|
"api-reference/endpoints/secret-syncs/heroku/sync-secrets",
|
||||||
|
"api-reference/endpoints/secret-syncs/heroku/remove-secrets"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"group": "Humanitec",
|
"group": "Humanitec",
|
||||||
"pages": [
|
"pages": [
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export const TtlFormLabel = ({ label }: { label: string }) => (
|
|||||||
<FontAwesomeIcon
|
<FontAwesomeIcon
|
||||||
icon={faQuestionCircle}
|
icon={faQuestionCircle}
|
||||||
size="sm"
|
size="sm"
|
||||||
className="relative bottom-1 right-1"
|
className="relative bottom-px right-1"
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import { Controller, useFormContext, useWatch } from "react-hook-form";
|
||||||
|
import { SingleValue } from "react-select";
|
||||||
|
import { faCircleInfo } from "@fortawesome/free-solid-svg-icons";
|
||||||
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
|
||||||
|
import { SecretSyncConnectionField } from "@app/components/secret-syncs/forms/SecretSyncConnectionField";
|
||||||
|
import { FilterableSelect, FormControl, Tooltip } from "@app/components/v2";
|
||||||
|
import { THerokuApp } from "@app/hooks/api/appConnections/heroku";
|
||||||
|
import { useHerokuConnectionListApps } from "@app/hooks/api/appConnections/heroku/queries";
|
||||||
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
|
||||||
|
import { TSecretSyncForm } from "../schemas";
|
||||||
|
|
||||||
|
export const HerokuSyncFields = () => {
|
||||||
|
const { control, setValue } = useFormContext<
|
||||||
|
TSecretSyncForm & { destination: SecretSync.Heroku }
|
||||||
|
>();
|
||||||
|
|
||||||
|
const connectionId = useWatch({ name: "connection.id", control });
|
||||||
|
|
||||||
|
const { data: apps, isLoading: isAppsLoading } = useHerokuConnectionListApps(connectionId, {
|
||||||
|
enabled: Boolean(connectionId)
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SecretSyncConnectionField
|
||||||
|
onChange={() => {
|
||||||
|
setValue("destinationConfig.app", "");
|
||||||
|
setValue("destinationConfig.appName", "");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
name="destinationConfig.app"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
isError={Boolean(error)}
|
||||||
|
errorText={error?.message}
|
||||||
|
label="App"
|
||||||
|
helperText={
|
||||||
|
<Tooltip
|
||||||
|
className="max-w-md"
|
||||||
|
content="Ensure the app exists in the connection's Heroku instance URL."
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<span>Don't see the app you're looking for?</span>{" "}
|
||||||
|
<FontAwesomeIcon icon={faCircleInfo} className="text-mineshaft-400" />
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<FilterableSelect
|
||||||
|
menuPlacement="top"
|
||||||
|
isLoading={isAppsLoading && Boolean(connectionId)}
|
||||||
|
isDisabled={!connectionId}
|
||||||
|
value={apps?.find((app) => app.id === value) ?? null}
|
||||||
|
onChange={(option) => {
|
||||||
|
onChange((option as SingleValue<THerokuApp>)?.id ?? "");
|
||||||
|
setValue(
|
||||||
|
"destinationConfig.appName",
|
||||||
|
(option as SingleValue<THerokuApp>)?.name ?? ""
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
options={apps}
|
||||||
|
placeholder="Select an app..."
|
||||||
|
getOptionLabel={(option) => option.name}
|
||||||
|
getOptionValue={(option) => option.id}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -16,6 +16,7 @@ import { FlyioSyncFields } from "./FlyioSyncFields";
|
|||||||
import { GcpSyncFields } from "./GcpSyncFields";
|
import { GcpSyncFields } from "./GcpSyncFields";
|
||||||
import { GitHubSyncFields } from "./GitHubSyncFields";
|
import { GitHubSyncFields } from "./GitHubSyncFields";
|
||||||
import { HCVaultSyncFields } from "./HCVaultSyncFields";
|
import { HCVaultSyncFields } from "./HCVaultSyncFields";
|
||||||
|
import { HerokuSyncFields } from "./HerokuSyncFields";
|
||||||
import { HumanitecSyncFields } from "./HumanitecSyncFields";
|
import { HumanitecSyncFields } from "./HumanitecSyncFields";
|
||||||
import { OCIVaultSyncFields } from "./OCIVaultSyncFields";
|
import { OCIVaultSyncFields } from "./OCIVaultSyncFields";
|
||||||
import { RenderSyncFields } from "./RenderSyncFields";
|
import { RenderSyncFields } from "./RenderSyncFields";
|
||||||
@@ -64,6 +65,8 @@ export const SecretSyncDestinationFields = () => {
|
|||||||
return <OCIVaultSyncFields />;
|
return <OCIVaultSyncFields />;
|
||||||
case SecretSync.OnePass:
|
case SecretSync.OnePass:
|
||||||
return <OnePassSyncFields />;
|
return <OnePassSyncFields />;
|
||||||
|
case SecretSync.Heroku:
|
||||||
|
return <HerokuSyncFields />;
|
||||||
case SecretSync.Render:
|
case SecretSync.Render:
|
||||||
return <RenderSyncFields />;
|
return <RenderSyncFields />;
|
||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export const SecretSyncOptionsFields = ({ hideInitialSync }: Props) => {
|
|||||||
case SecretSync.TeamCity:
|
case SecretSync.TeamCity:
|
||||||
case SecretSync.OnePass:
|
case SecretSync.OnePass:
|
||||||
case SecretSync.OCIVault:
|
case SecretSync.OCIVault:
|
||||||
|
case SecretSync.Heroku:
|
||||||
case SecretSync.Render:
|
case SecretSync.Render:
|
||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
case SecretSync.CloudflarePages:
|
case SecretSync.CloudflarePages:
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { useFormContext } from "react-hook-form";
|
||||||
|
|
||||||
|
import { GenericFieldLabel } from "@app/components/secret-syncs";
|
||||||
|
import { TSecretSyncForm } from "@app/components/secret-syncs/forms/schemas";
|
||||||
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
|
||||||
|
export const HerokuSyncReviewFields = () => {
|
||||||
|
const { watch } = useFormContext<TSecretSyncForm & { destination: SecretSync.Heroku }>();
|
||||||
|
const appName = watch("destinationConfig.appName");
|
||||||
|
const appId = watch("destinationConfig.app");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<GenericFieldLabel label="App">{appName}</GenericFieldLabel>
|
||||||
|
<GenericFieldLabel label="App ID">{appId}</GenericFieldLabel>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -25,6 +25,7 @@ import { FlyioSyncReviewFields } from "./FlyioSyncReviewFields";
|
|||||||
import { GcpSyncReviewFields } from "./GcpSyncReviewFields";
|
import { GcpSyncReviewFields } from "./GcpSyncReviewFields";
|
||||||
import { GitHubSyncReviewFields } from "./GitHubSyncReviewFields";
|
import { GitHubSyncReviewFields } from "./GitHubSyncReviewFields";
|
||||||
import { HCVaultSyncReviewFields } from "./HCVaultSyncReviewFields";
|
import { HCVaultSyncReviewFields } from "./HCVaultSyncReviewFields";
|
||||||
|
import { HerokuSyncReviewFields } from "./HerokuSyncReviewFields";
|
||||||
import { HumanitecSyncReviewFields } from "./HumanitecSyncReviewFields";
|
import { HumanitecSyncReviewFields } from "./HumanitecSyncReviewFields";
|
||||||
import { OCIVaultSyncReviewFields } from "./OCIVaultSyncReviewFields";
|
import { OCIVaultSyncReviewFields } from "./OCIVaultSyncReviewFields";
|
||||||
import { OnePassSyncReviewFields } from "./OnePassSyncReviewFields";
|
import { OnePassSyncReviewFields } from "./OnePassSyncReviewFields";
|
||||||
@@ -107,6 +108,9 @@ export const SecretSyncReviewFields = () => {
|
|||||||
case SecretSync.OnePass:
|
case SecretSync.OnePass:
|
||||||
DestinationFieldsComponent = <OnePassSyncReviewFields />;
|
DestinationFieldsComponent = <OnePassSyncReviewFields />;
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.Heroku:
|
||||||
|
DestinationFieldsComponent = <HerokuSyncReviewFields />;
|
||||||
|
break;
|
||||||
case SecretSync.Render:
|
case SecretSync.Render:
|
||||||
DestinationFieldsComponent = <RenderSyncReviewFields />;
|
DestinationFieldsComponent = <RenderSyncReviewFields />;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import { BaseSecretSyncSchema } from "@app/components/secret-syncs/forms/schemas/base-secret-sync-schema";
|
||||||
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
|
||||||
|
export const HerokuSyncDestinationSchema = BaseSecretSyncSchema().merge(
|
||||||
|
z.object({
|
||||||
|
destination: z.literal(SecretSync.Heroku),
|
||||||
|
destinationConfig: z.object({
|
||||||
|
app: z.string().trim().min(1, "App ID required"),
|
||||||
|
appName: z.string().trim().min(1, "App name required")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
);
|
||||||
@@ -13,6 +13,7 @@ import { FlyioSyncDestinationSchema } from "./flyio-sync-destination-schema";
|
|||||||
import { GcpSyncDestinationSchema } from "./gcp-sync-destination-schema";
|
import { GcpSyncDestinationSchema } from "./gcp-sync-destination-schema";
|
||||||
import { GitHubSyncDestinationSchema } from "./github-sync-destination-schema";
|
import { GitHubSyncDestinationSchema } from "./github-sync-destination-schema";
|
||||||
import { HCVaultSyncDestinationSchema } from "./hc-vault-sync-destination-schema";
|
import { HCVaultSyncDestinationSchema } from "./hc-vault-sync-destination-schema";
|
||||||
|
import { HerokuSyncDestinationSchema } from "./heroku-sync-destination-schema";
|
||||||
import { HumanitecSyncDestinationSchema } from "./humanitec-sync-destination-schema";
|
import { HumanitecSyncDestinationSchema } from "./humanitec-sync-destination-schema";
|
||||||
import { OCIVaultSyncDestinationSchema } from "./oci-vault-sync-destination-schema";
|
import { OCIVaultSyncDestinationSchema } from "./oci-vault-sync-destination-schema";
|
||||||
import { RenderSyncDestinationSchema } from "./render-sync-destination-schema";
|
import { RenderSyncDestinationSchema } from "./render-sync-destination-schema";
|
||||||
@@ -39,6 +40,7 @@ const SecretSyncUnionSchema = z.discriminatedUnion("destination", [
|
|||||||
TeamCitySyncDestinationSchema,
|
TeamCitySyncDestinationSchema,
|
||||||
OCIVaultSyncDestinationSchema,
|
OCIVaultSyncDestinationSchema,
|
||||||
OnePassSyncDestinationSchema,
|
OnePassSyncDestinationSchema,
|
||||||
|
HerokuSyncDestinationSchema,
|
||||||
RenderSyncDestinationSchema,
|
RenderSyncDestinationSchema,
|
||||||
FlyioSyncDestinationSchema,
|
FlyioSyncDestinationSchema,
|
||||||
CloudflarePagesSyncDestinationSchema
|
CloudflarePagesSyncDestinationSchema
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ import {
|
|||||||
VercelConnectionMethod,
|
VercelConnectionMethod,
|
||||||
WindmillConnectionMethod
|
WindmillConnectionMethod
|
||||||
} from "@app/hooks/api/appConnections/types";
|
} from "@app/hooks/api/appConnections/types";
|
||||||
|
import { HerokuConnectionMethod } from "@app/hooks/api/appConnections/types/heroku-connection";
|
||||||
import { OCIConnectionMethod } from "@app/hooks/api/appConnections/types/oci-connection";
|
import { OCIConnectionMethod } from "@app/hooks/api/appConnections/types/oci-connection";
|
||||||
import { RenderConnectionMethod } from "@app/hooks/api/appConnections/types/render-connection";
|
import { RenderConnectionMethod } from "@app/hooks/api/appConnections/types/render-connection";
|
||||||
|
|
||||||
@@ -82,6 +83,7 @@ export const APP_CONNECTION_MAP: Record<
|
|||||||
[AppConnection.TeamCity]: { name: "TeamCity", image: "TeamCity.png" },
|
[AppConnection.TeamCity]: { name: "TeamCity", image: "TeamCity.png" },
|
||||||
[AppConnection.OCI]: { name: "OCI", image: "Oracle.png", enterprise: true },
|
[AppConnection.OCI]: { name: "OCI", image: "Oracle.png", enterprise: true },
|
||||||
[AppConnection.OnePass]: { name: "1Password", image: "1Password.png" },
|
[AppConnection.OnePass]: { name: "1Password", image: "1Password.png" },
|
||||||
|
[AppConnection.Heroku]: { name: "Heroku", image: "Heroku.png" },
|
||||||
[AppConnection.Render]: { name: "Render", image: "Render.png" },
|
[AppConnection.Render]: { name: "Render", image: "Render.png" },
|
||||||
[AppConnection.Flyio]: { name: "Fly.io", image: "Flyio.svg" },
|
[AppConnection.Flyio]: { name: "Fly.io", image: "Flyio.svg" },
|
||||||
[AppConnection.Cloudflare]: { name: "Cloudflare", image: "Cloudflare.png" }
|
[AppConnection.Cloudflare]: { name: "Cloudflare", image: "Cloudflare.png" }
|
||||||
@@ -97,6 +99,7 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])
|
|||||||
case AzureClientSecretsConnectionMethod.OAuth:
|
case AzureClientSecretsConnectionMethod.OAuth:
|
||||||
case AzureDevOpsConnectionMethod.OAuth:
|
case AzureDevOpsConnectionMethod.OAuth:
|
||||||
case GitHubConnectionMethod.OAuth:
|
case GitHubConnectionMethod.OAuth:
|
||||||
|
case HerokuConnectionMethod.OAuth:
|
||||||
return { name: "OAuth", icon: faPassport };
|
return { name: "OAuth", icon: faPassport };
|
||||||
case AwsConnectionMethod.AccessKey:
|
case AwsConnectionMethod.AccessKey:
|
||||||
case OCIConnectionMethod.AccessKey:
|
case OCIConnectionMethod.AccessKey:
|
||||||
@@ -132,6 +135,8 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])
|
|||||||
return { name: "App Role", icon: faUser };
|
return { name: "App Role", icon: faUser };
|
||||||
case LdapConnectionMethod.SimpleBind:
|
case LdapConnectionMethod.SimpleBind:
|
||||||
return { name: "Simple Bind", icon: faLink };
|
return { name: "Simple Bind", icon: faLink };
|
||||||
|
case HerokuConnectionMethod.AuthToken:
|
||||||
|
return { name: "Auth Token", icon: faKey };
|
||||||
case RenderConnectionMethod.ApiKey:
|
case RenderConnectionMethod.ApiKey:
|
||||||
return { name: "API Key", icon: faKey };
|
return { name: "API Key", icon: faKey };
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -62,6 +62,10 @@ export const SECRET_SYNC_MAP: Record<SecretSync, { name: string; image: string }
|
|||||||
name: "1Password",
|
name: "1Password",
|
||||||
image: "1Password.png"
|
image: "1Password.png"
|
||||||
},
|
},
|
||||||
|
[SecretSync.Heroku]: {
|
||||||
|
name: "Heroku",
|
||||||
|
image: "Heroku.png"
|
||||||
|
},
|
||||||
[SecretSync.Render]: {
|
[SecretSync.Render]: {
|
||||||
name: "Render",
|
name: "Render",
|
||||||
image: "Render.png"
|
image: "Render.png"
|
||||||
@@ -94,6 +98,7 @@ export const SECRET_SYNC_CONNECTION_MAP: Record<SecretSync, AppConnection> = {
|
|||||||
[SecretSync.TeamCity]: AppConnection.TeamCity,
|
[SecretSync.TeamCity]: AppConnection.TeamCity,
|
||||||
[SecretSync.OCIVault]: AppConnection.OCI,
|
[SecretSync.OCIVault]: AppConnection.OCI,
|
||||||
[SecretSync.OnePass]: AppConnection.OnePass,
|
[SecretSync.OnePass]: AppConnection.OnePass,
|
||||||
|
[SecretSync.Heroku]: AppConnection.Heroku,
|
||||||
[SecretSync.Render]: AppConnection.Render,
|
[SecretSync.Render]: AppConnection.Render,
|
||||||
[SecretSync.Flyio]: AppConnection.Flyio,
|
[SecretSync.Flyio]: AppConnection.Flyio,
|
||||||
[SecretSync.CloudflarePages]: AppConnection.Cloudflare
|
[SecretSync.CloudflarePages]: AppConnection.Cloudflare
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export type Approver = {
|
|||||||
id: string;
|
id: string;
|
||||||
type: ApproverType;
|
type: ApproverType;
|
||||||
sequence?: number;
|
sequence?: number;
|
||||||
approvals?: number;
|
approvalsRequired?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Bypasser = {
|
export type Bypasser = {
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export enum AppConnection {
|
|||||||
TeamCity = "teamcity",
|
TeamCity = "teamcity",
|
||||||
OCI = "oci",
|
OCI = "oci",
|
||||||
OnePass = "1password",
|
OnePass = "1password",
|
||||||
|
Heroku = "heroku",
|
||||||
Render = "render",
|
Render = "render",
|
||||||
Flyio = "flyio",
|
Flyio = "flyio",
|
||||||
Cloudflare = "cloudflare"
|
Cloudflare = "cloudflare"
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from "./queries";
|
||||||
|
export * from "./types";
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
import { apiRequest } from "@app/config/request";
|
||||||
|
|
||||||
|
import { appConnectionKeys } from "../queries";
|
||||||
|
import { THerokuApp } from "./types";
|
||||||
|
|
||||||
|
const herokuConnectionKeys = {
|
||||||
|
all: [...appConnectionKeys.all, "heroku"] as const,
|
||||||
|
listApps: (connectionId: string) => [...herokuConnectionKeys.all, "apps", connectionId] as const
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useHerokuConnectionListApps = (
|
||||||
|
connectionId: string,
|
||||||
|
options?: Omit<
|
||||||
|
UseQueryOptions<
|
||||||
|
THerokuApp[],
|
||||||
|
unknown,
|
||||||
|
THerokuApp[],
|
||||||
|
ReturnType<typeof herokuConnectionKeys.listApps>
|
||||||
|
>,
|
||||||
|
"queryKey" | "queryFn"
|
||||||
|
>
|
||||||
|
) => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: herokuConnectionKeys.listApps(connectionId),
|
||||||
|
queryFn: async () => {
|
||||||
|
const { data } = await apiRequest.get<THerokuApp[]>(
|
||||||
|
`/api/v1/app-connections/heroku/${connectionId}/apps`
|
||||||
|
);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
...options
|
||||||
|
});
|
||||||
|
};
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export type THerokuApp = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
@@ -106,6 +106,11 @@ export type TOCIConnectionOption = TAppConnectionOptionBase & {
|
|||||||
app: AppConnection.OCI;
|
app: AppConnection.OCI;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type THerokuConnectionOption = TAppConnectionOptionBase & {
|
||||||
|
app: AppConnection.Heroku;
|
||||||
|
oauthClientId?: string;
|
||||||
|
};
|
||||||
|
|
||||||
export type TOnePassConnectionOption = TAppConnectionOptionBase & {
|
export type TOnePassConnectionOption = TAppConnectionOptionBase & {
|
||||||
app: AppConnection.OnePass;
|
app: AppConnection.OnePass;
|
||||||
};
|
};
|
||||||
@@ -145,6 +150,7 @@ export type TAppConnectionOption =
|
|||||||
| TTeamCityConnectionOption
|
| TTeamCityConnectionOption
|
||||||
| TOCIConnectionOption
|
| TOCIConnectionOption
|
||||||
| TOnePassConnectionOption
|
| TOnePassConnectionOption
|
||||||
|
| THerokuConnectionOption
|
||||||
| TRenderConnectionOption
|
| TRenderConnectionOption
|
||||||
| TFlyioConnectionOption
|
| TFlyioConnectionOption
|
||||||
| TCloudflareConnectionOption;
|
| TCloudflareConnectionOption;
|
||||||
@@ -174,6 +180,7 @@ export type TAppConnectionOptionMap = {
|
|||||||
[AppConnection.TeamCity]: TTeamCityConnectionOption;
|
[AppConnection.TeamCity]: TTeamCityConnectionOption;
|
||||||
[AppConnection.OCI]: TOCIConnectionOption;
|
[AppConnection.OCI]: TOCIConnectionOption;
|
||||||
[AppConnection.OnePass]: TOnePassConnectionOption;
|
[AppConnection.OnePass]: TOnePassConnectionOption;
|
||||||
|
[AppConnection.Heroku]: THerokuConnectionOption;
|
||||||
[AppConnection.Render]: TRenderConnectionOption;
|
[AppConnection.Render]: TRenderConnectionOption;
|
||||||
[AppConnection.Flyio]: TFlyioConnectionOption;
|
[AppConnection.Flyio]: TFlyioConnectionOption;
|
||||||
[AppConnection.Cloudflare]: TCloudflareConnectionOption;
|
[AppConnection.Cloudflare]: TCloudflareConnectionOption;
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||||
|
import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-connection";
|
||||||
|
|
||||||
|
export enum HerokuConnectionMethod {
|
||||||
|
AuthToken = "auth-token",
|
||||||
|
OAuth = "oauth"
|
||||||
|
}
|
||||||
|
|
||||||
|
export type THerokuConnection = TRootAppConnection & { app: AppConnection.Heroku } & (
|
||||||
|
| {
|
||||||
|
method: HerokuConnectionMethod.AuthToken;
|
||||||
|
credentials: {
|
||||||
|
authToken: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
method: HerokuConnectionMethod.OAuth;
|
||||||
|
credentials: {
|
||||||
|
code: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -15,6 +15,7 @@ import { TGcpConnection } from "./gcp-connection";
|
|||||||
import { TGitHubConnection } from "./github-connection";
|
import { TGitHubConnection } from "./github-connection";
|
||||||
import { TGitHubRadarConnection } from "./github-radar-connection";
|
import { TGitHubRadarConnection } from "./github-radar-connection";
|
||||||
import { THCVaultConnection } from "./hc-vault-connection";
|
import { THCVaultConnection } from "./hc-vault-connection";
|
||||||
|
import { THerokuConnection } from "./heroku-connection";
|
||||||
import { THumanitecConnection } from "./humanitec-connection";
|
import { THumanitecConnection } from "./humanitec-connection";
|
||||||
import { TLdapConnection } from "./ldap-connection";
|
import { TLdapConnection } from "./ldap-connection";
|
||||||
import { TMsSqlConnection } from "./mssql-connection";
|
import { TMsSqlConnection } from "./mssql-connection";
|
||||||
@@ -42,6 +43,7 @@ export * from "./gcp-connection";
|
|||||||
export * from "./github-connection";
|
export * from "./github-connection";
|
||||||
export * from "./github-radar-connection";
|
export * from "./github-radar-connection";
|
||||||
export * from "./hc-vault-connection";
|
export * from "./hc-vault-connection";
|
||||||
|
export * from "./heroku-connection";
|
||||||
export * from "./humanitec-connection";
|
export * from "./humanitec-connection";
|
||||||
export * from "./ldap-connection";
|
export * from "./ldap-connection";
|
||||||
export * from "./mssql-connection";
|
export * from "./mssql-connection";
|
||||||
@@ -81,6 +83,7 @@ export type TAppConnection =
|
|||||||
| TTeamCityConnection
|
| TTeamCityConnection
|
||||||
| TOCIConnection
|
| TOCIConnection
|
||||||
| TOnePassConnection
|
| TOnePassConnection
|
||||||
|
| THerokuConnection
|
||||||
| TRenderConnection
|
| TRenderConnection
|
||||||
| TFlyioConnection
|
| TFlyioConnection
|
||||||
| TCloudflareConnection;
|
| TCloudflareConnection;
|
||||||
@@ -135,6 +138,7 @@ export type TAppConnectionMap = {
|
|||||||
[AppConnection.TeamCity]: TTeamCityConnection;
|
[AppConnection.TeamCity]: TTeamCityConnection;
|
||||||
[AppConnection.OCI]: TOCIConnection;
|
[AppConnection.OCI]: TOCIConnection;
|
||||||
[AppConnection.OnePass]: TOnePassConnection;
|
[AppConnection.OnePass]: TOnePassConnection;
|
||||||
|
[AppConnection.Heroku]: THerokuConnection;
|
||||||
[AppConnection.Render]: TRenderConnection;
|
[AppConnection.Render]: TRenderConnection;
|
||||||
[AppConnection.Flyio]: TFlyioConnection;
|
[AppConnection.Flyio]: TFlyioConnection;
|
||||||
[AppConnection.Cloudflare]: TCloudflareConnection;
|
[AppConnection.Cloudflare]: TCloudflareConnection;
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ export type TDynamicSecret = {
|
|||||||
defaultTTL: string;
|
defaultTTL: string;
|
||||||
status?: DynamicSecretStatus;
|
status?: DynamicSecretStatus;
|
||||||
statusDetails?: string;
|
statusDetails?: string;
|
||||||
maxTTL: string;
|
maxTTL?: string;
|
||||||
usernameTemplate?: string | null;
|
usernameTemplate?: string | null;
|
||||||
metadata?: { key: string; value: string }[];
|
metadata?: { key: string; value: string }[];
|
||||||
|
tags?: { key: string; value: string }[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export enum DynamicSecretProviders {
|
export enum DynamicSecretProviders {
|
||||||
@@ -35,7 +36,8 @@ export enum DynamicSecretProviders {
|
|||||||
SapAse = "sap-ase",
|
SapAse = "sap-ase",
|
||||||
Kubernetes = "kubernetes",
|
Kubernetes = "kubernetes",
|
||||||
Vertica = "vertica",
|
Vertica = "vertica",
|
||||||
GcpIam = "gcp-iam"
|
GcpIam = "gcp-iam",
|
||||||
|
Github = "github"
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum KubernetesDynamicSecretCredentialType {
|
export enum KubernetesDynamicSecretCredentialType {
|
||||||
@@ -89,6 +91,7 @@ export type TDynamicSecretProvider =
|
|||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: DynamicSecretProviders.AwsIam;
|
type: DynamicSecretProviders.AwsIam;
|
||||||
|
tags?: { key: string; value: string }[];
|
||||||
inputs:
|
inputs:
|
||||||
| {
|
| {
|
||||||
method: DynamicSecretAwsIamAuth.AccessKey;
|
method: DynamicSecretAwsIamAuth.AccessKey;
|
||||||
@@ -333,6 +336,14 @@ export type TDynamicSecretProvider =
|
|||||||
inputs: {
|
inputs: {
|
||||||
serviceAccountEmail: string;
|
serviceAccountEmail: string;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: DynamicSecretProviders.Github;
|
||||||
|
inputs: {
|
||||||
|
appId: number;
|
||||||
|
installationId: number;
|
||||||
|
privateKey: string;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TCreateDynamicSecretDTO = {
|
export type TCreateDynamicSecretDTO = {
|
||||||
@@ -345,6 +356,7 @@ export type TCreateDynamicSecretDTO = {
|
|||||||
name: string;
|
name: string;
|
||||||
metadata?: { key: string; value: string }[];
|
metadata?: { key: string; value: string }[];
|
||||||
usernameTemplate?: string;
|
usernameTemplate?: string;
|
||||||
|
tags?: { key: string; value: string }[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type TUpdateDynamicSecretDTO = {
|
export type TUpdateDynamicSecretDTO = {
|
||||||
@@ -359,6 +371,7 @@ export type TUpdateDynamicSecretDTO = {
|
|||||||
maxTTL?: string | null;
|
maxTTL?: string | null;
|
||||||
inputs?: unknown;
|
inputs?: unknown;
|
||||||
usernameTemplate?: string | null;
|
usernameTemplate?: string | null;
|
||||||
|
tags?: { key: string; value: string }[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ export enum SecretSync {
|
|||||||
TeamCity = "teamcity",
|
TeamCity = "teamcity",
|
||||||
OCIVault = "oci-vault",
|
OCIVault = "oci-vault",
|
||||||
OnePass = "1password",
|
OnePass = "1password",
|
||||||
|
Heroku = "heroku",
|
||||||
Render = "render",
|
Render = "render",
|
||||||
Flyio = "flyio",
|
Flyio = "flyio",
|
||||||
CloudflarePages = "cloudflare-pages"
|
CloudflarePages = "cloudflare-pages"
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
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 THerokuSync = TRootSecretSync & {
|
||||||
|
destination: SecretSync.Heroku;
|
||||||
|
destinationConfig: {
|
||||||
|
app: string;
|
||||||
|
appName: string;
|
||||||
|
};
|
||||||
|
connection: {
|
||||||
|
app: AppConnection.Heroku;
|
||||||
|
name: string;
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -15,6 +15,7 @@ import { TFlyioSync } from "./flyio-sync";
|
|||||||
import { TGcpSync } from "./gcp-sync";
|
import { TGcpSync } from "./gcp-sync";
|
||||||
import { TGitHubSync } from "./github-sync";
|
import { TGitHubSync } from "./github-sync";
|
||||||
import { THCVaultSync } from "./hc-vault-sync";
|
import { THCVaultSync } from "./hc-vault-sync";
|
||||||
|
import { THerokuSync } from "./heroku-sync";
|
||||||
import { THumanitecSync } from "./humanitec-sync";
|
import { THumanitecSync } from "./humanitec-sync";
|
||||||
import { TOCIVaultSync } from "./oci-vault-sync";
|
import { TOCIVaultSync } from "./oci-vault-sync";
|
||||||
import { TTeamCitySync } from "./teamcity-sync";
|
import { TTeamCitySync } from "./teamcity-sync";
|
||||||
@@ -47,6 +48,7 @@ export type TSecretSync =
|
|||||||
| TTeamCitySync
|
| TTeamCitySync
|
||||||
| TOCIVaultSync
|
| TOCIVaultSync
|
||||||
| TOnePassSync
|
| TOnePassSync
|
||||||
|
| THerokuSync
|
||||||
| TRenderSync
|
| TRenderSync
|
||||||
| TFlyioSync
|
| TFlyioSync
|
||||||
| TCloudflarePagesSync;
|
| TCloudflarePagesSync;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import { GcpConnectionForm } from "./GcpConnectionForm";
|
|||||||
import { GitHubConnectionForm } from "./GitHubConnectionForm";
|
import { GitHubConnectionForm } from "./GitHubConnectionForm";
|
||||||
import { GitHubRadarConnectionForm } from "./GitHubRadarConnectionForm";
|
import { GitHubRadarConnectionForm } from "./GitHubRadarConnectionForm";
|
||||||
import { HCVaultConnectionForm } from "./HCVaultConnectionForm";
|
import { HCVaultConnectionForm } from "./HCVaultConnectionForm";
|
||||||
|
import { HerokuConnectionForm } from "./HerokuAppConnectionForm";
|
||||||
import { HumanitecConnectionForm } from "./HumanitecConnectionForm";
|
import { HumanitecConnectionForm } from "./HumanitecConnectionForm";
|
||||||
import { LdapConnectionForm } from "./LdapConnectionForm";
|
import { LdapConnectionForm } from "./LdapConnectionForm";
|
||||||
import { MsSqlConnectionForm } from "./MsSqlConnectionForm";
|
import { MsSqlConnectionForm } from "./MsSqlConnectionForm";
|
||||||
@@ -122,6 +123,8 @@ const CreateForm = ({ app, onComplete }: CreateFormProps) => {
|
|||||||
return <OCIConnectionForm onSubmit={onSubmit} />;
|
return <OCIConnectionForm onSubmit={onSubmit} />;
|
||||||
case AppConnection.OnePass:
|
case AppConnection.OnePass:
|
||||||
return <OnePassConnectionForm onSubmit={onSubmit} />;
|
return <OnePassConnectionForm onSubmit={onSubmit} />;
|
||||||
|
case AppConnection.Heroku:
|
||||||
|
return <HerokuConnectionForm onSubmit={onSubmit} />;
|
||||||
case AppConnection.Render:
|
case AppConnection.Render:
|
||||||
return <RenderConnectionForm onSubmit={onSubmit} />;
|
return <RenderConnectionForm onSubmit={onSubmit} />;
|
||||||
case AppConnection.Flyio:
|
case AppConnection.Flyio:
|
||||||
@@ -212,6 +215,8 @@ const UpdateForm = ({ appConnection, onComplete }: UpdateFormProps) => {
|
|||||||
return <OCIConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
return <OCIConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||||
case AppConnection.OnePass:
|
case AppConnection.OnePass:
|
||||||
return <OnePassConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
return <OnePassConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||||
|
case AppConnection.Heroku:
|
||||||
|
return <HerokuConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||||
case AppConnection.Render:
|
case AppConnection.Render:
|
||||||
return <RenderConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
return <RenderConnectionForm onSubmit={onSubmit} appConnection={appConnection} />;
|
||||||
case AppConnection.Flyio:
|
case AppConnection.Flyio:
|
||||||
|
|||||||
@@ -0,0 +1,253 @@
|
|||||||
|
/* eslint-disable no-case-declarations */
|
||||||
|
/* eslint-disable no-nested-ternary */
|
||||||
|
import crypto from "crypto";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Controller, FormProvider, useForm } from "react-hook-form";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
import {
|
||||||
|
Button,
|
||||||
|
FormControl,
|
||||||
|
ModalClose,
|
||||||
|
SecretInput,
|
||||||
|
Select,
|
||||||
|
SelectItem
|
||||||
|
} from "@app/components/v2";
|
||||||
|
import { APP_CONNECTION_MAP, getAppConnectionMethodDetails } from "@app/helpers/appConnections";
|
||||||
|
import { isInfisicalCloud } from "@app/helpers/platform";
|
||||||
|
import { useGetAppConnectionOption } from "@app/hooks/api/appConnections";
|
||||||
|
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||||
|
import {
|
||||||
|
HerokuConnectionMethod,
|
||||||
|
THerokuConnection
|
||||||
|
} from "@app/hooks/api/appConnections/types/heroku-connection";
|
||||||
|
|
||||||
|
import {
|
||||||
|
genericAppConnectionFieldsSchema,
|
||||||
|
GenericAppConnectionsFields
|
||||||
|
} from "./GenericAppConnectionFields";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
appConnection?: THerokuConnection;
|
||||||
|
onSubmit: (formData: FormData) => Promise<void>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const formSchema = z.discriminatedUnion("method", [
|
||||||
|
genericAppConnectionFieldsSchema.extend({
|
||||||
|
app: z.literal(AppConnection.Heroku),
|
||||||
|
method: z.literal(HerokuConnectionMethod.AuthToken),
|
||||||
|
credentials: z.object({
|
||||||
|
authToken: z.string().min(1, "Auth token is required")
|
||||||
|
})
|
||||||
|
}),
|
||||||
|
genericAppConnectionFieldsSchema.extend({
|
||||||
|
app: z.literal(AppConnection.Heroku),
|
||||||
|
method: z.literal(HerokuConnectionMethod.OAuth),
|
||||||
|
credentials: z.object({
|
||||||
|
code: z.string().min(1, "Code is required")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
|
||||||
|
type FormData = z.infer<typeof formSchema>;
|
||||||
|
|
||||||
|
export const HerokuConnectionForm = ({ appConnection, onSubmit: formSubmit }: Props) => {
|
||||||
|
const isUpdate = Boolean(appConnection);
|
||||||
|
const [isRedirecting, setIsRedirecting] = useState(false);
|
||||||
|
|
||||||
|
const {
|
||||||
|
option: { oauthClientId },
|
||||||
|
isLoading
|
||||||
|
} = useGetAppConnectionOption(AppConnection.Heroku);
|
||||||
|
|
||||||
|
const form = useForm<FormData>({
|
||||||
|
resolver: zodResolver(formSchema),
|
||||||
|
defaultValues:
|
||||||
|
appConnection?.method === HerokuConnectionMethod.OAuth
|
||||||
|
? { ...appConnection, credentials: { code: "custom" } }
|
||||||
|
: (appConnection ??
|
||||||
|
({
|
||||||
|
app: AppConnection.Heroku,
|
||||||
|
method: HerokuConnectionMethod.AuthToken,
|
||||||
|
credentials: {
|
||||||
|
authToken: ""
|
||||||
|
}
|
||||||
|
} as FormData))
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
handleSubmit,
|
||||||
|
control,
|
||||||
|
watch,
|
||||||
|
setValue,
|
||||||
|
formState: { isSubmitting, isDirty }
|
||||||
|
} = form;
|
||||||
|
|
||||||
|
const selectedMethod = watch("method");
|
||||||
|
|
||||||
|
const onSubmit = async (formData: FormData) => {
|
||||||
|
try {
|
||||||
|
switch (formData.method) {
|
||||||
|
case HerokuConnectionMethod.AuthToken:
|
||||||
|
await formSubmit(formData);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HerokuConnectionMethod.OAuth:
|
||||||
|
if (!oauthClientId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setIsRedirecting(true);
|
||||||
|
|
||||||
|
// Generate CSRF token
|
||||||
|
const state = crypto.randomBytes(16).toString("hex");
|
||||||
|
|
||||||
|
// Store state and form data for callback
|
||||||
|
localStorage.setItem("latestCSRFToken", state);
|
||||||
|
localStorage.setItem(
|
||||||
|
"herokuConnectionFormData",
|
||||||
|
JSON.stringify({
|
||||||
|
...formData,
|
||||||
|
connectionId: appConnection?.id,
|
||||||
|
isUpdate
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// Redirect to Heroku OAuth
|
||||||
|
const oauthUrl = new URL("https://id.heroku.com/oauth/authorize");
|
||||||
|
oauthUrl.searchParams.set("client_id", oauthClientId);
|
||||||
|
oauthUrl.searchParams.set("response_type", "code");
|
||||||
|
oauthUrl.searchParams.set("scope", "write-protected");
|
||||||
|
oauthUrl.searchParams.set("state", state);
|
||||||
|
|
||||||
|
window.location.assign(oauthUrl.toString());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Error("Unhandled Heroku Connection method");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error handling form submission:", error);
|
||||||
|
setIsRedirecting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let isMissingConfig: boolean;
|
||||||
|
|
||||||
|
switch (selectedMethod) {
|
||||||
|
case HerokuConnectionMethod.OAuth:
|
||||||
|
isMissingConfig = !oauthClientId;
|
||||||
|
break;
|
||||||
|
case HerokuConnectionMethod.AuthToken:
|
||||||
|
isMissingConfig = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new Error(`Unhandled Heroku Connection method: ${selectedMethod}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const methodDetails = getAppConnectionMethodDetails(selectedMethod);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<FormProvider {...form}>
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
{!isUpdate && <GenericAppConnectionsFields />}
|
||||||
|
|
||||||
|
<Controller
|
||||||
|
name="method"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
tooltipText={`The method you would like to use to connect with ${
|
||||||
|
APP_CONNECTION_MAP[AppConnection.Heroku].name
|
||||||
|
}. This field cannot be changed after creation.`}
|
||||||
|
errorText={
|
||||||
|
!isLoading && isMissingConfig && selectedMethod === HerokuConnectionMethod.OAuth
|
||||||
|
? `Environment variables have not been configured. ${
|
||||||
|
isInfisicalCloud()
|
||||||
|
? "Please contact Infisical."
|
||||||
|
: `See Docs to configure Heroku ${methodDetails.name} Connections.`
|
||||||
|
}`
|
||||||
|
: error?.message
|
||||||
|
}
|
||||||
|
isError={Boolean(error?.message) || isMissingConfig}
|
||||||
|
label="Method"
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
isDisabled={isUpdate}
|
||||||
|
value={value}
|
||||||
|
onValueChange={(val) => {
|
||||||
|
console.log("val", val === HerokuConnectionMethod.OAuth);
|
||||||
|
onChange(val);
|
||||||
|
if (val === HerokuConnectionMethod.OAuth) {
|
||||||
|
setValue("credentials.code", "custom");
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="w-full border border-mineshaft-500"
|
||||||
|
position="popper"
|
||||||
|
dropdownContainerClassName="max-w-none"
|
||||||
|
>
|
||||||
|
{Object.values(HerokuConnectionMethod).map((method) => {
|
||||||
|
return (
|
||||||
|
<SelectItem value={method} key={method}>
|
||||||
|
{getAppConnectionMethodDetails(method).name}{" "}
|
||||||
|
{method === HerokuConnectionMethod.AuthToken ? " (Recommended)" : ""}
|
||||||
|
</SelectItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{selectedMethod === HerokuConnectionMethod.AuthToken && (
|
||||||
|
<Controller
|
||||||
|
name="credentials.authToken"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
|
<FormControl
|
||||||
|
label="Auth Token"
|
||||||
|
errorText={error?.message}
|
||||||
|
isError={Boolean(error?.message)}
|
||||||
|
tooltipText="Your Heroku Auth Token"
|
||||||
|
>
|
||||||
|
<SecretInput
|
||||||
|
containerClassName="text-gray-400 group-focus-within:!border-primary-400/50 border border-mineshaft-500 bg-mineshaft-900 px-2.5 py-1.5"
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => onChange(e.target.value)}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div className="mt-8 flex items-center">
|
||||||
|
<Button
|
||||||
|
className="mr-4"
|
||||||
|
size="sm"
|
||||||
|
type="submit"
|
||||||
|
colorSchema="secondary"
|
||||||
|
isLoading={isSubmitting || isRedirecting}
|
||||||
|
isDisabled={
|
||||||
|
isSubmitting ||
|
||||||
|
(!isUpdate && !isDirty) ||
|
||||||
|
(isMissingConfig && selectedMethod === HerokuConnectionMethod.OAuth) ||
|
||||||
|
isRedirecting
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{isRedirecting && selectedMethod === HerokuConnectionMethod.OAuth
|
||||||
|
? "Redirecting to Heroku..."
|
||||||
|
: isUpdate
|
||||||
|
? "Reconnect to Heroku"
|
||||||
|
: "Connect to Heroku"}
|
||||||
|
</Button>
|
||||||
|
<ModalClose asChild>
|
||||||
|
<Button colorSchema="secondary" variant="plain">
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
</ModalClose>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</FormProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { THerokuSync } from "@app/hooks/api/secretSyncs/types/heroku-sync";
|
||||||
|
|
||||||
|
import { getSecretSyncDestinationColValues } from "../helpers";
|
||||||
|
import { SecretSyncTableCell } from "../SecretSyncTableCell";
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
secretSync: THerokuSync;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const HerokuSyncDestinationCol = ({ secretSync }: Props) => {
|
||||||
|
const { primaryText, secondaryText } = getSecretSyncDestinationColValues(secretSync);
|
||||||
|
|
||||||
|
return <SecretSyncTableCell primaryText={primaryText} secondaryText={secondaryText} />;
|
||||||
|
};
|
||||||
@@ -13,6 +13,7 @@ import { FlyioSyncDestinationCol } from "./FlyioSyncDestinationCol";
|
|||||||
import { GcpSyncDestinationCol } from "./GcpSyncDestinationCol";
|
import { GcpSyncDestinationCol } from "./GcpSyncDestinationCol";
|
||||||
import { GitHubSyncDestinationCol } from "./GitHubSyncDestinationCol";
|
import { GitHubSyncDestinationCol } from "./GitHubSyncDestinationCol";
|
||||||
import { HCVaultSyncDestinationCol } from "./HCVaultSyncDestinationCol";
|
import { HCVaultSyncDestinationCol } from "./HCVaultSyncDestinationCol";
|
||||||
|
import { HerokuSyncDestinationCol } from "./HerokuSyncDestinationCol";
|
||||||
import { HumanitecSyncDestinationCol } from "./HumanitecSyncDestinationCol";
|
import { HumanitecSyncDestinationCol } from "./HumanitecSyncDestinationCol";
|
||||||
import { OCIVaultSyncDestinationCol } from "./OCIVaultSyncDestinationCol";
|
import { OCIVaultSyncDestinationCol } from "./OCIVaultSyncDestinationCol";
|
||||||
import { RenderSyncDestinationCol } from "./RenderSyncDestinationCol";
|
import { RenderSyncDestinationCol } from "./RenderSyncDestinationCol";
|
||||||
@@ -61,6 +62,8 @@ export const SecretSyncDestinationCol = ({ secretSync }: Props) => {
|
|||||||
return <OnePassSyncDestinationCol secretSync={secretSync} />;
|
return <OnePassSyncDestinationCol secretSync={secretSync} />;
|
||||||
case SecretSync.AzureDevOps:
|
case SecretSync.AzureDevOps:
|
||||||
return <AzureDevOpsSyncDestinationCol secretSync={secretSync} />;
|
return <AzureDevOpsSyncDestinationCol secretSync={secretSync} />;
|
||||||
|
case SecretSync.Heroku:
|
||||||
|
return <HerokuSyncDestinationCol secretSync={secretSync} />;
|
||||||
case SecretSync.Render:
|
case SecretSync.Render:
|
||||||
return <RenderSyncDestinationCol secretSync={secretSync} />;
|
return <RenderSyncDestinationCol secretSync={secretSync} />;
|
||||||
case SecretSync.Flyio:
|
case SecretSync.Flyio:
|
||||||
|
|||||||
@@ -116,6 +116,10 @@ export const getSecretSyncDestinationColValues = (secretSync: TSecretSync) => {
|
|||||||
primaryText = destinationConfig.devopsProjectName;
|
primaryText = destinationConfig.devopsProjectName;
|
||||||
secondaryText = destinationConfig.devopsProjectId;
|
secondaryText = destinationConfig.devopsProjectId;
|
||||||
break;
|
break;
|
||||||
|
case SecretSync.Heroku:
|
||||||
|
primaryText = destinationConfig.appName;
|
||||||
|
secondaryText = destinationConfig.app;
|
||||||
|
break;
|
||||||
case SecretSync.Render:
|
case SecretSync.Render:
|
||||||
primaryText = destinationConfig.serviceName ?? destinationConfig.serviceId;
|
primaryText = destinationConfig.serviceName ?? destinationConfig.serviceId;
|
||||||
secondaryText = "Service";
|
secondaryText = "Service";
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ export const ReviewAccessRequestModal = ({
|
|||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
const approvals = curr.approvals || policy.approvals;
|
const approvals = curr.approvalsRequired || policy.approvals;
|
||||||
const sequence = curr.sequence || 1;
|
const sequence = curr.sequence || 1;
|
||||||
|
|
||||||
acc.push(
|
acc.push(
|
||||||
|
|||||||