Skip to content

Commit

Permalink
Add supabase docs, modify integration docs wording, check integration…
Browse files Browse the repository at this point in the history
… middleware
  • Loading branch information
dangtony98 committed Apr 14, 2023
1 parent d824305 commit b21a8b4
Show file tree
Hide file tree
Showing 29 changed files with 73 additions and 45 deletions.
2 changes: 1 addition & 1 deletion backend/src/helpers/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ interface Update {
if (!integration) throw IntegrationNotFoundError();

const integrationAuth = await IntegrationAuth
.findById(integrationId)
.findById(integration.integrationAuth)
.select(
'+refreshCiphertext +refreshIV +refreshTag +accessCiphertext +accessIV +accessTag +accessExpiresAt'
);
Expand Down
19 changes: 12 additions & 7 deletions backend/src/helpers/integrationAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,34 @@ import { validateServiceAccountClientForWorkspace } from '../helpers/serviceAcco
*/
const validateClientForIntegrationAuth = async ({
authData,
integrationId,
acceptedRoles
integrationAuthId,
acceptedRoles,
attachAccessToken
}: {
authData: {
authMode: string;
authPayload: IUser | IServiceAccount | IServiceTokenData;
};
integrationId: Types.ObjectId;
integrationAuthId: Types.ObjectId;
acceptedRoles: Array<'admin' | 'member'>;
attachAccessToken?: boolean;
}) => {

const integrationAuth = await IntegrationAuth
.findById(integrationId)
.findById(integrationAuthId)
.populate<{ workspace: IWorkspace }>('workspace')
.select(
'+refreshCiphertext +refreshIV +refreshTag +accessCiphertext +accessIV +accessTag +accessExpiresAt'
);

if (!integrationAuth) throw IntegrationAuthNotFoundError();

const accessToken = (await IntegrationService.getIntegrationAuthAccess({
integrationAuthId: integrationAuth._id
})).accessToken;
let accessToken;
if (attachAccessToken) {
accessToken = (await IntegrationService.getIntegrationAuthAccess({
integrationAuthId: integrationAuth._id
})).accessToken;
}

if (authData.authMode === AUTH_MODE_JWT && authData.authPayload instanceof User) {
await validateUserClientForWorkspace({
Expand Down
4 changes: 1 addition & 3 deletions backend/src/middleware/requireIntegrationAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ const requireIntegrationAuth = ({
acceptedRoles: Array<'admin' | 'member'>;
}) => {
return async (req: Request, res: Response, next: NextFunction) => {
// integration authorization middleware

const { integrationId } = req.params;

const { integration, accessToken } = await validateClientForIntegration({
authData: req.authData,
integrationId: new Types.ObjectId(integrationId),
Expand Down
7 changes: 4 additions & 3 deletions backend/src/middleware/requireIntegrationAuthorizationAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ const requireIntegrationAuthorizationAuth = ({
}) => {
return async (req: Request, res: Response, next: NextFunction) => {
const { integrationAuthId } = req[location];

const { integrationAuth, accessToken } = await validateClientForIntegrationAuth({
authData: req.authData,
integrationId: new Types.ObjectId(integrationAuthId),
acceptedRoles
integrationAuthId: new Types.ObjectId(integrationAuthId),
acceptedRoles,
attachAccessToken
});

if (integrationAuth) {
Expand Down
18 changes: 9 additions & 9 deletions backend/src/middleware/requireMembershipAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ const requireMembershipAuth = ({
res: Response,
next: NextFunction
) => {
const { membershipId } = req[locationMembershipId];
req.targetMembership = await validateClientForMembership({
authData: req.authData,
membershipId: new Types.ObjectId(membershipId),
acceptedRoles
});
return next();
const { membershipId } = req[locationMembershipId];

req.targetMembership = await validateClientForMembership({
authData: req.authData,
membershipId: new Types.ObjectId(membershipId),
acceptedRoles
});

return next();
}
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/integrations-supabase-create.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/integrations-supabase-dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/integrations-supabase-token.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/integrations-supabase.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/integrations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/integrations/cicd/circleci.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "CircleCI"
description: "How to automatically sync secrets from Infisical into your CircleCI project."
description: "How to sync secrets from Infisical to CircleCI"
---

Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/cicd/githubactions.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "GitHub Actions"
description: "How to automatically sync secrets from Infisical into your GitHub Actions."
description: "How to sync secrets from Infisical to GitHub Actions"
---

<Warning>
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/cicd/gitlab.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "GitLab"
description: "How to automatically sync secrets from Infisical into GitLab."
description: "How to sync secrets from Infisical to GitLab"
---

Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/cicd/travisci.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Travis CI"
description: "How to automatically sync secrets from Infisical to your Travis CI repository."
description: "How to sync secrets from Infisical to Travis CI"
---

Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/cloud/aws-parameter-store.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "AWS Parameter Store"
description: "How to automatically sync secrets from Infisical to your AWS Parameter Store."
description: "How to sync secrets from Infisical to AWS Parameter Store"
---

Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/cloud/aws-secret-manager.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "AWS Secret Manager"
description: "How to automatically sync secrets from Infisical to your AWS Secret Manager."
description: "How to sync secrets from Infisical to AWS Secret Manager"
---

Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/cloud/azure-key-vault.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Azure Key Vault"
description: "How to automatically sync secrets from Infisical into your Azure Key Vault."
description: "How to sync secrets from Infisical to Azure Key Vault"
---

Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/cloud/flyio.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Fly.io"
description: "How to automatically sync secrets from Infisical into your Fly.io project."
description: "How to sync secrets from Infisical to Fly.io"
---

Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/cloud/heroku.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Heroku"
description: "How to automatically sync secrets from Infisical into your Heroku project."
description: "How to sync secrets from Infisical to Heroku"
---

Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/cloud/netlify.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Netlify"
description: "How to automatically sync secrets from Infisical into your Netlify project."
description: "How to sync secrets from Infisical to Netlify"
---

<Warning>
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/cloud/railway.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Railway"
description: "How to automatically sync secrets from Infisical into your Railway projects and services"
description: "How to sync secrets from Infisical to Railway"
---

Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/cloud/render.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Render"
description: "How to automatically sync secrets from Infisical into your Render project."
description: "How to sync secrets from Infisical to Render"
---

Prerequisites:
Expand Down
34 changes: 29 additions & 5 deletions docs/integrations/cloud/supabase.mdx
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
---
title: "Supabase"
description: "How to automatically sync secrets from Infisical into your Supabase project."
description: "How to sync secrets from Infisical to Supabase"
---

<Note>
The Supabase integration is useful if your Supabase project uses sensitive-information such as [environment variables in edge functions](https://supabase.com/docs/guides/functions/secrets).

Synced envars can be accessed in edge functions using Deno's built-in handler: `Deno.env.get(MY_SECRET_NAME)`.
</Note>

Prerequisites:

- Have an account and project set up at [Supabase](https://supabase.com/)
- Set up and add envars to [Infisical Cloud](https://app.infisical.com)

Note somewhere that envars will be accessible in edge functions etc.

## Navigate to your project's integrations tab

![integrations](../../images/integrations.png)

## Enter your Supabase API
## Enter your Supabase Access Token

Obtain a Supabase Access Token in your Supabase [Account > Access Tokens](https://app.supabase.com/account/tokens).
![integrations supabase dashboard](../../images/integrations-supabase-dashboard.png)
![integrations supabase token](../../images/integrations-supabase-token.png)

Press on the Supabase tile and input your Supabase Access Token to grant Infisical access to your Supabase account.

![integrations supabase authorization](../../images/integrations-supabase-authorization.png)

<Info>
If this is your project's first cloud integration, then you'll have to grant
Infisical access to your project's environment variables. Although this step
breaks E2EE, it's necessary for Infisical to sync the environment variables to
the cloud platform.
</Info>

## Start integration

Select which Infisical environment secrets you want to sync to which Supabase project. Lastly, press create integration to start syncing secrets to Supabase.

![integrations supabase create](../../images/integrations-supabase-create.png)

## Start integration
![integrations supabase](../../images/integrations-supabase.png)
2 changes: 1 addition & 1 deletion docs/integrations/cloud/vercel.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Vercel"
description: "How to automatically sync secrets from Infisical into your Vercel project."
description: "How to sync secrets from Infisical to Vercel"
---

Prerequisites:
Expand Down
4 changes: 2 additions & 2 deletions docs/integrations/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ Missing an integration? Throw in a [request](https://github.com/Infisical/infisi
| [Vercel](/integrations/cloud/vercel) | Cloud | Available |
| [Netlify](/integrations/cloud/netlify) | Cloud | Available |
| [Render](/integrations/cloud/render) | Cloud | Available |
| [Railway](/integrations/cloud/railway) | Cloud | Available |
| [Railway](/integrations/cloud/railway) | Cloud | Available |
| [Fly.io](/integrations/cloud/flyio) | Cloud | Available |
| [Supabase](/integrations/cloud/flyio) | Cloud | Available |
| [Supabase](/integrations/cloud/supabase) | Cloud | Available |
| [AWS Parameter Store](/integrations/cloud/aws-parameter-store) | Cloud | Available |
| [AWS Secret Manager](/integrations/cloud/aws-secret-manager) | Cloud | Available |
| [Azure Key Vault](/integrations/cloud/azure-key-vault) | Cloud | Available |
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations/platforms/kubernetes.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 'Kubernetes'
description: "This page explains how to use Infisical to inject secrets into Kubernetes clusters."
description: "How to use Infisical to inject secrets into Kubernetes clusters."
---

![title](../../images/k8-diagram.png)
Expand Down
1 change: 1 addition & 0 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
"integrations/cloud/render",
"integrations/cloud/railway",
"integrations/cloud/flyio",
"integrations/cloud/supabase",
"integrations/cloud/azure-key-vault",
"integrations/cicd/githubactions",
"integrations/cicd/gitlab",
Expand Down
1 change: 0 additions & 1 deletion frontend/src/pages/api/integrations/DeleteIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const deleteIntegration = ({ integrationId }: Props) =>
if (res && res.status === 200) {
return (await res.json()).integration;
}
console.log('Failed to delete an integration');
return undefined;
});

Expand Down

0 comments on commit b21a8b4

Please sign in to comment.