mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-03 22:26:07 +00:00
Modify case where integration bot was authorized but user didn't finish inputting their PAT -> should result in not sharing keys with bot
This commit is contained in:
@@ -25,7 +25,6 @@ const requireIntegrationAuthorizationAuth = ({
|
|||||||
}) => {
|
}) => {
|
||||||
return async (req: Request, res: Response, next: NextFunction) => {
|
return async (req: Request, res: Response, next: NextFunction) => {
|
||||||
const { integrationAuthId } = req[location];
|
const { integrationAuthId } = req[location];
|
||||||
|
|
||||||
const integrationAuth = await IntegrationAuth.findOne({
|
const integrationAuth = await IntegrationAuth.findOne({
|
||||||
_id: integrationAuthId
|
_id: integrationAuthId
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ type Props = {
|
|||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
closeModal: () => void;
|
closeModal: () => void;
|
||||||
selectedIntegrationOption: IntegrationOption | null;
|
selectedIntegrationOption: IntegrationOption | null;
|
||||||
handleBotActivate: () => Promise<void>;
|
|
||||||
integrationOptionPress: (integrationOption: IntegrationOption) => void;
|
integrationOptionPress: (integrationOption: IntegrationOption) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -27,20 +26,16 @@ const ActivateBotDialog = ({
|
|||||||
isOpen,
|
isOpen,
|
||||||
closeModal,
|
closeModal,
|
||||||
selectedIntegrationOption,
|
selectedIntegrationOption,
|
||||||
handleBotActivate,
|
|
||||||
integrationOptionPress
|
integrationOptionPress
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
try {
|
try {
|
||||||
// 1. activate bot
|
|
||||||
await handleBotActivate();
|
|
||||||
|
|
||||||
// type check
|
// type check
|
||||||
if (!selectedIntegrationOption) return;
|
if (!selectedIntegrationOption) return;
|
||||||
|
|
||||||
// 2. start integration or probe for PAT
|
// start integration or probe for PAT
|
||||||
integrationOptionPress(selectedIntegrationOption);
|
integrationOptionPress(selectedIntegrationOption);
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ const IntegrationAccessTokenDialog = ({
|
|||||||
<div>
|
<div>
|
||||||
<Transition appear show={isOpen} as={Fragment}>
|
<Transition appear show={isOpen} as={Fragment}>
|
||||||
<Dialog as="div" className="relative z-10" onClose={() => {
|
<Dialog as="div" className="relative z-10" onClose={() => {
|
||||||
console.log('onClose');
|
|
||||||
closeModal();
|
closeModal();
|
||||||
}}>
|
}}>
|
||||||
<Transition.Child
|
<Transition.Child
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ const ProjectIntegrationSection = ({
|
|||||||
setBot,
|
setBot,
|
||||||
environments = [],
|
environments = [],
|
||||||
handleDeleteIntegration
|
handleDeleteIntegration
|
||||||
}: Props) =>
|
}: Props) => {
|
||||||
integrations.length > 0 ? (
|
return integrations.length > 0 ? (
|
||||||
<div className="mb-12">
|
<div className="mb-12">
|
||||||
<div className="flex flex-col justify-between items-start mx-4 mb-4 mt-6 text-xl max-w-5xl px-2">
|
<div className="flex flex-col justify-between items-start mx-4 mb-4 mt-6 text-xl max-w-5xl px-2">
|
||||||
<h1 className="font-semibold text-3xl">Current Integrations</h1>
|
<h1 className="font-semibold text-3xl">Current Integrations</h1>
|
||||||
@@ -40,7 +40,6 @@ const ProjectIntegrationSection = ({
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{integrations.map((integration: Integration) => {
|
{integrations.map((integration: Integration) => {
|
||||||
console.log('IntegrationSection integration: ', integration);
|
|
||||||
return (
|
return (
|
||||||
<IntegrationTile
|
<IntegrationTile
|
||||||
key={`integration-${integration._id.toString()}`}
|
key={`integration-${integration._id.toString()}`}
|
||||||
@@ -58,5 +57,6 @@ const ProjectIntegrationSection = ({
|
|||||||
) : (
|
) : (
|
||||||
<div />
|
<div />
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export default ProjectIntegrationSection;
|
export default ProjectIntegrationSection;
|
||||||
@@ -183,6 +183,10 @@ export default function Integrations() {
|
|||||||
accessToken?: string;
|
accessToken?: string;
|
||||||
}) => {
|
}) => {
|
||||||
try {
|
try {
|
||||||
|
if (!bot.isActive) {
|
||||||
|
await handleBotActivate();
|
||||||
|
}
|
||||||
|
|
||||||
if (integrationOption.type === 'oauth') {
|
if (integrationOption.type === 'oauth') {
|
||||||
// integration is of type OAuth
|
// integration is of type OAuth
|
||||||
|
|
||||||
@@ -233,7 +237,7 @@ export default function Integrations() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -247,6 +251,7 @@ export default function Integrations() {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const integrationOptionPress = async (integrationOption: IntegrationOption) => {
|
const integrationOptionPress = async (integrationOption: IntegrationOption) => {
|
||||||
|
// consider: don't start integration until at [handleIntegrationOption] step
|
||||||
try {
|
try {
|
||||||
const integrationAuthX = integrationAuths.find((integrationAuth) => integrationAuth.integration === integrationOption.slug);
|
const integrationAuthX = integrationAuths.find((integrationAuth) => integrationAuth.integration === integrationOption.slug);
|
||||||
|
|
||||||
@@ -264,12 +269,15 @@ export default function Integrations() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!bot.isActive) {
|
||||||
|
await handleBotActivate();
|
||||||
|
}
|
||||||
|
|
||||||
// case: integration has been authorized before
|
// case: integration has been authorized before
|
||||||
// -> create new integration
|
// -> create new integration
|
||||||
const integration = await createIntegration({
|
const integration = await createIntegration({
|
||||||
integrationAuthId: integrationAuthX._id
|
integrationAuthId: integrationAuthX._id
|
||||||
});
|
});
|
||||||
|
|
||||||
setIntegrations([...integrations, integration]);
|
setIntegrations([...integrations, integration]);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@@ -350,7 +358,6 @@ export default function Integrations() {
|
|||||||
isOpen={isActivateBotDialogOpen}
|
isOpen={isActivateBotDialogOpen}
|
||||||
closeModal={() => setIsActivateBotDialogOpen(false)}
|
closeModal={() => setIsActivateBotDialogOpen(false)}
|
||||||
selectedIntegrationOption={selectedIntegrationOption}
|
selectedIntegrationOption={selectedIntegrationOption}
|
||||||
handleBotActivate={handleBotActivate}
|
|
||||||
integrationOptionPress={integrationOptionPress}
|
integrationOptionPress={integrationOptionPress}
|
||||||
/>
|
/>
|
||||||
<IntegrationAccessTokenDialog
|
<IntegrationAccessTokenDialog
|
||||||
@@ -358,7 +365,6 @@ export default function Integrations() {
|
|||||||
closeModal={() => setIntegrationAccessTokenDialogOpen(false)}
|
closeModal={() => setIntegrationAccessTokenDialogOpen(false)}
|
||||||
selectedIntegrationOption={selectedIntegrationOption}
|
selectedIntegrationOption={selectedIntegrationOption}
|
||||||
handleIntegrationOption={handleIntegrationOption}
|
handleIntegrationOption={handleIntegrationOption}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
<IntegrationSection
|
<IntegrationSection
|
||||||
integrations={integrations}
|
integrations={integrations}
|
||||||
|
|||||||
Reference in New Issue
Block a user