mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-10 07:28:50 +00:00
Fix more merge conflicts and continue cleaning up integrations frontend
This commit is contained in:
@@ -28,7 +28,6 @@ const CloudIntegration = ({
|
|||||||
deleteIntegrationAuth,
|
deleteIntegrationAuth,
|
||||||
authorizations
|
authorizations
|
||||||
}: CloudIntegration) => {
|
}: CloudIntegration) => {
|
||||||
console.log('cio', integration);
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`relative ${
|
className={`relative ${
|
||||||
|
|||||||
@@ -48,13 +48,8 @@ const getSecretsForProject = async ({
|
|||||||
publicKey: file.key.sender.publicKey,
|
publicKey: file.key.sender.publicKey,
|
||||||
privateKey: PRIVATE_KEY
|
privateKey: PRIVATE_KEY
|
||||||
});
|
});
|
||||||
<<<<<<< HEAD:frontend/components/utilities/secrets/getSecretsForProject.js
|
|
||||||
|
|
||||||
file.secrets.map((secretPair) => {
|
|
||||||
=======
|
|
||||||
|
|
||||||
file.secrets.map((secretPair: any) => {
|
file.secrets.map((secretPair: any) => {
|
||||||
>>>>>>> 158c51ff3cbcd9a8eab6c44e728232d79a1cbab9:frontend/components/utilities/secrets/getSecretsForProject.ts
|
|
||||||
// decrypt .env file with symmetric key
|
// decrypt .env file with symmetric key
|
||||||
const plainTextKey = decryptSymmetric({
|
const plainTextKey = decryptSymmetric({
|
||||||
ciphertext: secretPair.secretKey.ciphertext,
|
ciphertext: secretPair.secretKey.ciphertext,
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import SecurityClient from "~/utilities/SecurityClient.js";
|
import SecurityClient from "~/utilities/SecurityClient";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
workspaceId: string;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function fetches the bot for a project
|
* This function fetches the bot for a project
|
||||||
@@ -6,7 +10,7 @@ import SecurityClient from "~/utilities/SecurityClient.js";
|
|||||||
* @param {String} obj.workspaceId
|
* @param {String} obj.workspaceId
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const getBot = async ({ workspaceId }) => {
|
const getBot = async ({ workspaceId }: Props) => {
|
||||||
return SecurityClient.fetchCall(
|
return SecurityClient.fetchCall(
|
||||||
"/api/v1/bot/" + workspaceId,
|
"/api/v1/bot/" + workspaceId,
|
||||||
{
|
{
|
||||||
@@ -16,7 +20,7 @@ const getBot = async ({ workspaceId }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
).then(async (res) => {
|
).then(async (res) => {
|
||||||
if (res.status == 200) {
|
if (res && res.status == 200) {
|
||||||
return await res.json();
|
return await res.json();
|
||||||
} else {
|
} else {
|
||||||
console.log("Failed to get bot for project");
|
console.log("Failed to get bot for project");
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
import SecurityClient from "~/utilities/SecurityClient.js";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function fetches the bot for a project
|
|
||||||
* @param {Object} obj
|
|
||||||
* @param {String} obj.workspaceId
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
const setBotActiveStatus = async ({ botId, isActive, botKey }) => {
|
|
||||||
return SecurityClient.fetchCall(
|
|
||||||
"/api/v1/bot/" + botId + "/active",
|
|
||||||
{
|
|
||||||
method: "PATCH",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
isActive,
|
|
||||||
botKey
|
|
||||||
})
|
|
||||||
}
|
|
||||||
).then(async (res) => {
|
|
||||||
if (res.status == 200) {
|
|
||||||
return await res.json();
|
|
||||||
} else {
|
|
||||||
console.log("Failed to get bot for project");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export default setBotActiveStatus;
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import SecurityClient from "~/utilities/SecurityClient";
|
||||||
|
|
||||||
|
interface BotKey {
|
||||||
|
encryptedKey: string;
|
||||||
|
nonce: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
botId: string;
|
||||||
|
isActive: Boolean;
|
||||||
|
botKey: BotKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function sets the active status of a bot and shares a copy of
|
||||||
|
* the project key (encrypted under the bot's public key) with the
|
||||||
|
* project's bot
|
||||||
|
* @param {Object} obj
|
||||||
|
* @param {String} obj.botId
|
||||||
|
* @param {String} obj.isActive
|
||||||
|
* @param {Object} obj.botKey
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
const setBotActiveStatus = async ({ botId, isActive, botKey }: Props) => {
|
||||||
|
return SecurityClient.fetchCall(
|
||||||
|
"/api/v1/bot/" + botId + "/active",
|
||||||
|
{
|
||||||
|
method: "PATCH",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
isActive,
|
||||||
|
botKey
|
||||||
|
})
|
||||||
|
}
|
||||||
|
).then(async (res) => {
|
||||||
|
if (res && res.status == 200) {
|
||||||
|
return await res.json();
|
||||||
|
} else {
|
||||||
|
console.log("Failed to get bot for project");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default setBotActiveStatus;
|
||||||
@@ -18,30 +18,6 @@ import {
|
|||||||
faPerson,
|
faPerson,
|
||||||
faPlus,
|
faPlus,
|
||||||
faShuffle,
|
faShuffle,
|
||||||
<<<<<<< HEAD
|
|
||||||
faX,
|
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
import { Menu, Transition } from "@headlessui/react";
|
|
||||||
|
|
||||||
import Button from "~/components/basic/buttons/Button";
|
|
||||||
import ListBox from "~/components/basic/Listbox";
|
|
||||||
import BottonRightPopup from "~/components/basic/popups/BottomRightPopup";
|
|
||||||
import { useNotificationContext } from "~/components/context/Notifications/NotificationProvider";
|
|
||||||
import DashboardInputField from "~/components/dashboard/DashboardInputField";
|
|
||||||
import DropZone from "~/components/dashboard/DropZone";
|
|
||||||
import NavHeader from "~/components/navigation/NavHeader";
|
|
||||||
import getSecretsForProject from "~/components/utilities/secrets/getSecretsForProject";
|
|
||||||
import pushKeys from "~/components/utilities/secrets/pushKeys";
|
|
||||||
import guidGenerator from "~/utilities/randomId";
|
|
||||||
|
|
||||||
import { envMapping } from "../../public/data/frequentConstants";
|
|
||||||
import getWorkspaceIntegrations from "../api/integrations/getWorkspaceIntegrations";
|
|
||||||
import getUser from "../api/user/getUser";
|
|
||||||
import checkUserAction from "../api/userActions/checkUserAction";
|
|
||||||
import registerUserAction from "../api/userActions/registerUserAction";
|
|
||||||
import getWorkspaces from "../api/workspace/getWorkspaces";
|
|
||||||
=======
|
|
||||||
faX
|
faX
|
||||||
} from '@fortawesome/free-solid-svg-icons';
|
} from '@fortawesome/free-solid-svg-icons';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||||
@@ -65,7 +41,6 @@ import getUser from '../api/user/getUser';
|
|||||||
import checkUserAction from '../api/userActions/checkUserAction';
|
import checkUserAction from '../api/userActions/checkUserAction';
|
||||||
import registerUserAction from '../api/userActions/registerUserAction';
|
import registerUserAction from '../api/userActions/registerUserAction';
|
||||||
import getWorkspaces from '../api/workspace/getWorkspaces';
|
import getWorkspaces from '../api/workspace/getWorkspaces';
|
||||||
>>>>>>> 158c51ff3cbcd9a8eab6c44e728232d79a1cbab9
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This component represent a single row for an environemnt variable on the dashboard
|
* This component represent a single row for an environemnt variable on the dashboard
|
||||||
@@ -426,32 +401,6 @@ export default function Dashboard() {
|
|||||||
setButtonReady(false);
|
setButtonReady(false);
|
||||||
pushKeys({ obj, workspaceId: router.query.id, env });
|
pushKeys({ obj, workspaceId: router.query.id, env });
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
/**
|
|
||||||
* Check which integrations are active for this project and environment
|
|
||||||
* If there are any, update environment variables for those integrations
|
|
||||||
*/
|
|
||||||
let integrations = await getWorkspaceIntegrations({
|
|
||||||
workspaceId: router.query.id
|
|
||||||
});
|
|
||||||
integrations.map(async (integration) => {
|
|
||||||
if (
|
|
||||||
envMapping[env] == integration.environment &&
|
|
||||||
integration.isActive == true
|
|
||||||
) {
|
|
||||||
let objIntegration = Object.assign(
|
|
||||||
{},
|
|
||||||
...data.map((row) => ({ [row[2]]: row[3] }))
|
|
||||||
);
|
|
||||||
await pushKeysIntegration({
|
|
||||||
obj: objIntegration,
|
|
||||||
integrationId: integration._id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
>>>>>>> 158c51ff3cbcd9a8eab6c44e728232d79a1cbab9
|
|
||||||
// If this user has never saved environment variables before, show them a prompt to read docs
|
// If this user has never saved environment variables before, show them a prompt to read docs
|
||||||
if (!hasUserEverPushed) {
|
if (!hasUserEverPushed) {
|
||||||
setCheckDocsPopUpVisible(true);
|
setCheckDocsPopUpVisible(true);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const queryString = require("query-string");
|
|||||||
import AuthorizeIntegration from "./api/integrations/authorizeIntegration";
|
import AuthorizeIntegration from "./api/integrations/authorizeIntegration";
|
||||||
|
|
||||||
export default function Heroku() {
|
export default function Heroku() {
|
||||||
|
console.log('HEROKU PAGE');
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const parsedUrl = queryString.parse(router.asPath.split("?")[1]);
|
const parsedUrl = queryString.parse(router.asPath.split("?")[1]);
|
||||||
const code = parsedUrl.code;
|
const code = parsedUrl.code;
|
||||||
@@ -16,7 +17,11 @@ export default function Heroku() {
|
|||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
useEffect(async () => {
|
useEffect(async () => {
|
||||||
try {
|
try {
|
||||||
|
console.log('A');
|
||||||
|
console.log(state);
|
||||||
|
console.log(localStorage.getItem('latestCSRFToken'));
|
||||||
if (state == localStorage.getItem("latestCSRFToken")) {
|
if (state == localStorage.getItem("latestCSRFToken")) {
|
||||||
|
console.log('B');
|
||||||
await AuthorizeIntegration({
|
await AuthorizeIntegration({
|
||||||
workspaceId: localStorage.getItem("projectData.id"),
|
workspaceId: localStorage.getItem("projectData.id"),
|
||||||
code,
|
code,
|
||||||
@@ -25,6 +30,7 @@ export default function Heroku() {
|
|||||||
router.push("/integrations/" + localStorage.getItem("projectData.id"));
|
router.push("/integrations/" + localStorage.getItem("projectData.id"));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
console.log("Error - Not logged in yet");
|
console.log("Error - Not logged in yet");
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
|||||||
@@ -74,38 +74,38 @@ export default function Integrations() {
|
|||||||
* 4. Send encrypted project key to backend and set bot status to active
|
* 4. Send encrypted project key to backend and set bot status to active
|
||||||
*/
|
*/
|
||||||
const handleBotActivate = async () => {
|
const handleBotActivate = async () => {
|
||||||
|
let botKey;
|
||||||
try {
|
try {
|
||||||
const key = await getLatestFileKey({ workspaceId: router.query.id });
|
|
||||||
|
|
||||||
if (bot) {
|
if (bot) {
|
||||||
// case: there is a bot
|
// case: there is a bot
|
||||||
const PRIVATE_KEY = localStorage.getItem('PRIVATE_KEY');
|
const key = await getLatestFileKey({ workspaceId: router.query.id });
|
||||||
|
const PRIVATE_KEY = localStorage.getItem('PRIVATE_KEY');
|
||||||
|
|
||||||
const WORKSPACE_KEY = decryptAssymmetric({
|
const WORKSPACE_KEY = decryptAssymmetric({
|
||||||
ciphertext: key.latestKey.encryptedKey,
|
ciphertext: key.latestKey.encryptedKey,
|
||||||
nonce: key.latestKey.nonce,
|
nonce: key.latestKey.nonce,
|
||||||
publicKey: key.latestKey.sender.publicKey,
|
publicKey: key.latestKey.sender.publicKey,
|
||||||
privateKey: PRIVATE_KEY
|
privateKey: PRIVATE_KEY
|
||||||
});
|
});
|
||||||
|
|
||||||
const { ciphertext, nonce } = encryptAssymmetric({
|
const { ciphertext, nonce } = encryptAssymmetric({
|
||||||
plaintext: WORKSPACE_KEY,
|
plaintext: WORKSPACE_KEY,
|
||||||
publicKey: bot.publicKey,
|
publicKey: bot.publicKey,
|
||||||
privateKey: PRIVATE_KEY
|
privateKey: PRIVATE_KEY
|
||||||
});
|
});
|
||||||
|
|
||||||
botKey = {
|
botKey = {
|
||||||
encryptedKey: ciphertext,
|
encryptedKey: ciphertext,
|
||||||
nonce
|
nonce
|
||||||
}
|
|
||||||
|
|
||||||
// case: bot is not active
|
|
||||||
setBot((await setBotActiveStatus({
|
|
||||||
botId: bot._id,
|
|
||||||
isActive: bot.isActive ? false : true,
|
|
||||||
botKey
|
|
||||||
})).bot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setBot((await setBotActiveStatus({
|
||||||
|
botId: bot._id,
|
||||||
|
isActive: bot.isActive ? false : true,
|
||||||
|
botKey
|
||||||
|
})).bot);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
@@ -115,6 +115,9 @@ export default function Integrations() {
|
|||||||
* Start integration for a given integration option [integrationOption]
|
* Start integration for a given integration option [integrationOption]
|
||||||
* @param {Object} obj
|
* @param {Object} obj
|
||||||
* @param {Object} obj.integrationOption - an integration option
|
* @param {Object} obj.integrationOption - an integration option
|
||||||
|
* @param {String} obj.name
|
||||||
|
* @param {String} obj.type
|
||||||
|
* @param {String} obj.docsLink
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const handleIntegrationOption = async ({ integrationOption }) => {
|
const handleIntegrationOption = async ({ integrationOption }) => {
|
||||||
@@ -122,20 +125,23 @@ export default function Integrations() {
|
|||||||
|
|
||||||
// generate CSRF token for OAuth2 code-token exchange integrations
|
// generate CSRF token for OAuth2 code-token exchange integrations
|
||||||
const csrfToken = crypto.randomBytes(16).toString("hex");
|
const csrfToken = crypto.randomBytes(16).toString("hex");
|
||||||
|
localStorage.setItem('latestCSRFToken', csrfToken);
|
||||||
|
|
||||||
switch (integrationOption.name) {
|
switch (integrationOption.name) {
|
||||||
case 'Heroku':
|
case 'Heroku':
|
||||||
window.location = `https://id.heroku.com/oauth/authorize?client_id=7b1311a1-1cb2-4938-8adf-f37a399ec41b&response_type=code&scope=write-protected&state=${csrfToken}`;
|
window.location = `https://id.heroku.com/oauth/authorize?client_id=7b1311a1-1cb2-4938-8adf-f37a399ec41b&response_type=code&scope=write-protected&state=${csrfToken}`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call [handleIntegrationOption] if bot is active, else open dialog for user to grant
|
* Open dialog to activate bot if bot is not active.
|
||||||
* permission to share secretes with Infisical prior to starting any integration
|
* Otherwise, start integration [integrationOption]
|
||||||
* @param {Object} obj
|
* @param {Object} obj
|
||||||
* @param {String} obj.integrationOption - an integration option
|
* @param {Object} obj.integrationOption - an integration option
|
||||||
|
* @param {String} obj.name
|
||||||
|
* @param {String} obj.type
|
||||||
|
* @param {String} obj.docsLink
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const integrationOptionPress = ({ integrationOption }) => {
|
const integrationOptionPress = ({ integrationOption }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user