-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Feature: start the phase out for Native Integrations #4947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
95fdff7
5bd8fc9
dd37fa3
15c341b
40c80f4
5c7f07c
0e49aaf
ffe866e
f98b803
9ffb440
0186f25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
victorvhs017 marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| import { EventType } from "@app/ee/services/audit-log/audit-log-types"; | ||
| import { ApiDocsTags, INTEGRATION_AUTH } from "@app/lib/api-docs"; | ||
| import { ForbiddenRequestError } from "@app/lib/errors"; | ||
| import { readLimit, writeLimit } from "@app/server/config/rateLimiter"; | ||
| import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; | ||
| import { AuthMode } from "@app/services/auth/auth-type"; | ||
|
|
@@ -10,6 +11,9 @@ | |
|
|
||
| import { integrationAuthPubSchema } from "../sanitizedSchemas"; | ||
|
|
||
| const NATIVE_INTEGRATION_DEPRECATION_MESSAGE = | ||
| "We're moving Native Integrations to Secret Syncs. Check the documentation at https://infisical.com/docs/integrations/secret-syncs/overview. If the integration you need isn't available in the Secret Syncs, please get in touch with us at [email protected]."; | ||
|
|
||
| export const registerIntegrationAuthRouter = async (server: FastifyZodProvider) => { | ||
| server.route({ | ||
| method: "GET", | ||
|
|
@@ -333,27 +337,33 @@ | |
| }) | ||
| } | ||
| }, | ||
| handler: async (req) => { | ||
| const integrationAuth = await server.services.integrationAuth.saveIntegrationToken({ | ||
| actorId: req.permission.id, | ||
| actor: req.permission.type, | ||
| actorAuthMethod: req.permission.authMethod, | ||
| actorOrgId: req.permission.orgId, | ||
| projectId: req.body.workspaceId, | ||
| ...req.body | ||
| handler: async (_) => { | ||
| throw new ForbiddenRequestError({ | ||
| message: NATIVE_INTEGRATION_DEPRECATION_MESSAGE | ||
| }); | ||
victorvhs017 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| await server.services.auditLog.createAuditLog({ | ||
| ...req.auditLogInfo, | ||
| projectId: req.body.workspaceId, | ||
| event: { | ||
| type: EventType.AUTHORIZE_INTEGRATION, | ||
| metadata: { | ||
| integration: integrationAuth.integration | ||
| } | ||
| } | ||
| }); | ||
| return { integrationAuth }; | ||
| // We are keeping the old response commented out for an easy revert on the API if we need to before the full phase out. | ||
|
|
||
| // const integrationAuth = await server.services.integrationAuth.saveIntegrationToken({ | ||
| // actorId: req.permission.id, | ||
| // actor: req.permission.type, | ||
| // actorAuthMethod: req.permission.authMethod, | ||
| // actorOrgId: req.permission.orgId, | ||
| // projectId: req.body.workspaceId, | ||
| // ...req.body | ||
| // }); | ||
|
|
||
| // await server.services.auditLog.createAuditLog({ | ||
| // ...req.auditLogInfo, | ||
| // projectId: req.body.workspaceId, | ||
| // event: { | ||
| // type: EventType.AUTHORIZE_INTEGRATION, | ||
| // metadata: { | ||
| // integration: integrationAuth.integration | ||
| // } | ||
| // } | ||
| // }); | ||
| // return { integrationAuth }; | ||
| } | ||
victorvhs017 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,17 +3,19 @@ | |
| import { IntegrationsSchema } from "@app/db/schemas"; | ||
| import { EventType } from "@app/ee/services/audit-log/audit-log-types"; | ||
| import { ApiDocsTags, INTEGRATION } from "@app/lib/api-docs"; | ||
| import { ForbiddenRequestError } from "@app/lib/errors"; | ||
| import { removeTrailingSlash, shake } from "@app/lib/fn"; | ||
| import { readLimit, writeLimit } from "@app/server/config/rateLimiter"; | ||
| import { getTelemetryDistinctId } from "@app/server/lib/telemetry"; | ||
| import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; | ||
| import { AuthMode } from "@app/services/auth/auth-type"; | ||
| import { IntegrationMetadataSchema } from "@app/services/integration/integration-schema"; | ||
| import { Integrations } from "@app/services/integration-auth/integration-list"; | ||
| import { PostHogEventTypes, TIntegrationCreatedEvent } from "@app/services/telemetry/telemetry-types"; | ||
|
|
||
| import {} from "../sanitizedSchemas"; | ||
|
|
||
| const NATIVE_INTEGRATION_DEPRECATION_MESSAGE = | ||
| "We're moving Native Integrations to Secret Syncs. Check the documentation at https://infisical.com/docs/integrations/secret-syncs/overview. If the integration you need isn't available in the Secret Syncs, please get in touch with us at [email protected]."; | ||
|
|
||
| export const registerIntegrationRouter = async (server: FastifyZodProvider) => { | ||
| server.route({ | ||
| method: "POST", | ||
|
|
@@ -66,52 +68,58 @@ | |
| } | ||
| }, | ||
| onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]), | ||
| handler: async (req) => { | ||
| const { integration, integrationAuth } = await server.services.integration.createIntegration({ | ||
| actorId: req.permission.id, | ||
| actor: req.permission.type, | ||
| actorAuthMethod: req.permission.authMethod, | ||
| actorOrgId: req.permission.orgId, | ||
| ...req.body | ||
| handler: async (_) => { | ||
| throw new ForbiddenRequestError({ | ||
| message: NATIVE_INTEGRATION_DEPRECATION_MESSAGE | ||
| }); | ||
victorvhs017 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| const createIntegrationEventProperty = shake({ | ||
| integrationId: integration.id.toString(), | ||
| integration: integration.integration, | ||
| environment: req.body.sourceEnvironment, | ||
| secretPath: req.body.secretPath, | ||
| url: integration.url, | ||
| app: integration.app, | ||
| appId: integration.appId, | ||
| targetEnvironment: integration.targetEnvironment, | ||
| targetEnvironmentId: integration.targetEnvironmentId, | ||
| targetService: integration.targetService, | ||
| targetServiceId: integration.targetServiceId, | ||
| path: integration.path, | ||
| region: integration.region | ||
| }) as TIntegrationCreatedEvent["properties"]; | ||
| // We are keeping the old response commented out for an easy revert on the API if we need to before the full phase out. | ||
|
|
||
| await server.services.auditLog.createAuditLog({ | ||
| ...req.auditLogInfo, | ||
| projectId: integrationAuth.projectId, | ||
| event: { | ||
| type: EventType.CREATE_INTEGRATION, | ||
| // eslint-disable-next-line | ||
| metadata: createIntegrationEventProperty | ||
| } | ||
| }); | ||
| // const { integration, integrationAuth } = await server.services.integration.createIntegration({ | ||
| // actorId: req.permission.id, | ||
| // actor: req.permission.type, | ||
| // actorAuthMethod: req.permission.authMethod, | ||
| // actorOrgId: req.permission.orgId, | ||
| // ...req.body | ||
| // }); | ||
|
|
||
| await server.services.telemetry.sendPostHogEvents({ | ||
| event: PostHogEventTypes.IntegrationCreated, | ||
| organizationId: req.permission.orgId, | ||
| distinctId: getTelemetryDistinctId(req), | ||
| properties: { | ||
| ...createIntegrationEventProperty, | ||
| projectId: integrationAuth.projectId, | ||
| ...req.auditLogInfo | ||
| } | ||
| }); | ||
| return { integration }; | ||
| // const createIntegrationEventProperty = shake({ | ||
| // integrationId: integration.id.toString(), | ||
| // integration: integration.integration, | ||
| // environment: req.body.sourceEnvironment, | ||
| // secretPath: req.body.secretPath, | ||
| // url: integration.url, | ||
| // app: integration.app, | ||
| // appId: integration.appId, | ||
| // targetEnvironment: integration.targetEnvironment, | ||
| // targetEnvironmentId: integration.targetEnvironmentId, | ||
| // targetService: integration.targetService, | ||
| // targetServiceId: integration.targetServiceId, | ||
| // path: integration.path, | ||
| // region: integration.region | ||
| // }) as TIntegrationCreatedEvent["properties"]; | ||
|
|
||
| // await server.services.auditLog.createAuditLog({ | ||
| // ...req.auditLogInfo, | ||
| // projectId: integrationAuth.projectId, | ||
| // event: { | ||
| // type: EventType.CREATE_INTEGRATION, | ||
| // // eslint-disable-next-line | ||
| // metadata: createIntegrationEventProperty | ||
| // } | ||
| // }); | ||
|
|
||
| // await server.services.telemetry.sendPostHogEvents({ | ||
| // event: PostHogEventTypes.IntegrationCreated, | ||
| // organizationId: req.permission.orgId, | ||
| // distinctId: getTelemetryDistinctId(req), | ||
| // properties: { | ||
| // ...createIntegrationEventProperty, | ||
| // projectId: integrationAuth.projectId, | ||
| // ...req.auditLogInfo | ||
| // } | ||
| // }); | ||
| // return { integration }; | ||
| } | ||
victorvhs017 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }); | ||
|
|
||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.