Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ CSP_REPORT_ONLY=false
# - Set the log level (debug: most verbose, info: recommended for production, error: least verbose)
#
LOG_LEVEL=info
#
#
# - Telemetry is minimal, anonymous and helps us improve (set to false to disable).
#
# TELEMETRY=false
#
#

###############################################################################

TZ=UTC
Expand Down Expand Up @@ -115,4 +109,4 @@ FLAG_SERVE_CONNECT_UI=true

# ---- AWS
# AWS_ACCESS_KEY_ID=<ACCESS-KEY-ID>
# AWS_SECRET_ACCESS_KEY=<SECRET-ACCESS-KEY>
# AWS_SECRET_ACCESS_KEY=<SECRET-ACCESS-KEY>
1 change: 0 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ services:
- NANGO_DASHBOARD_USERNAME
- NANGO_DASHBOARD_PASSWORD
- LOG_LEVEL=${LOG_LEVEL:-info}
- TELEMETRY
- NANGO_SERVER_WEBSOCKETS_PATH
- NANGO_LOGS_ENABLED=${NANGO_LOGS_ENABLED:-false}
- NANGO_LOGS_ES_URL=${NANGO_LOGS_ES_URL:-http://nango-elasticsearch:9200}
Expand Down
4 changes: 1 addition & 3 deletions packages/persist/lib/server.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,9 @@ const initDb = async () => {
const connectionRes = await connectionService.upsertConnection({
connectionId: `conn-test`,
providerConfigKey: `provider-test`,
provider: 'google',
parsedRawCredentials: {} as AuthCredentials,
connectionConfig: {},
environmentId: env.id,
accountId: 0
environmentId: env.id
});
const connectionId = connectionRes[0]?.connection.id;
if (!connectionId) throw new Error('Connection not created');
Expand Down
8 changes: 2 additions & 6 deletions packages/server/lib/controllers/appAuth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import db from '@nangohq/database';
import { logContextGetter } from '@nangohq/logs';
import { AnalyticsTypes, analytics, configService, connectionService, environmentService, errorManager, getProvider, linkConnection } from '@nangohq/shared';
import { configService, connectionService, environmentService, errorManager, getProvider, linkConnection } from '@nangohq/shared';
import { stringifyError } from '@nangohq/utils';

import publisher from '../clients/publisher.client.js';
Expand Down Expand Up @@ -50,8 +50,6 @@ class AppAuthController {

const { environment, account } = environmentAndAccountLookup;

void analytics.track(AnalyticsTypes.PRE_APP_AUTH, account.id);

const { providerConfigKey, connectionId: receivedConnectionId, webSocketClientId: wsClientId } = session;
const logCtx = logContextGetter.get({ id: session.activityLogId, accountId: account.id });

Expand Down Expand Up @@ -156,11 +154,9 @@ class AppAuthController {
const [updatedConnection] = await connectionService.upsertConnection({
connectionId,
providerConfigKey,
provider: session.provider,
parsedRawCredentials: credentials as unknown as AuthCredentials,
connectionConfig,
environmentId: environment.id,
accountId: account.id
environmentId: environment.id
});
if (!updatedConnection) {
void logCtx.error('Failed to create connection');
Expand Down
6 changes: 1 addition & 5 deletions packages/server/lib/controllers/auth/postApiKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { z } from 'zod';
import db from '@nangohq/database';
import { defaultOperationExpiration, endUserToMeta, logContextGetter } from '@nangohq/logs';
import {
AnalyticsTypes,
ErrorSourceEnum,
LogActionEnum,
analytics,
configService,
connectionService,
errorManager,
Expand Down Expand Up @@ -101,7 +99,6 @@ export const postPublicApiKeyAuthorization = asyncWrapper<PostPublicApiKeyAuthor
},
{ account, environment }
);
void analytics.track(AnalyticsTypes.PRE_API_KEY_AUTH, account.id);

if (!isConnectSession) {
const checked = await hmacCheck({ environment, logCtx, providerConfigKey, connectionId, hmac, res });
Expand Down Expand Up @@ -172,8 +169,7 @@ export const postPublicApiKeyAuthorization = asyncWrapper<PostPublicApiKeyAuthor
connectionConfig,
metadata: {},
config,
environment,
account
environment
});
if (!updatedConnection) {
res.status(500).send({ error: { code: 'server_error', message: 'failed to create connection' } });
Expand Down
20 changes: 3 additions & 17 deletions packages/server/lib/controllers/auth/postAppStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,18 @@ import { z } from 'zod';

import db from '@nangohq/database';
import { defaultOperationExpiration, endUserToMeta, logContextGetter } from '@nangohq/logs';
import {
AnalyticsTypes,
ErrorSourceEnum,
LogActionEnum,
analytics,
configService,
connectionService,
errorManager,
getProvider,
linkConnection
} from '@nangohq/shared';
import { ErrorSourceEnum, LogActionEnum, configService, connectionService, errorManager, getProvider, linkConnection } from '@nangohq/shared';
import { metrics, stringifyError, zodErrorToHTTP } from '@nangohq/utils';

import { connectionCredential, connectionIdSchema, providerConfigKeySchema } from '../../helpers/validation.js';
import { connectionCreated as connectionCreatedHook, connectionCreationFailed as connectionCreationFailedHook } from '../../hooks/hooks.js';
import { asyncWrapper } from '../../utils/asyncWrapper.js';
import { errorRestrictConnectionId, isIntegrationAllowed } from '../../utils/auth.js';
import { hmacCheck } from '../../utils/hmac.js';

import type { LogContext } from '@nangohq/logs';
import type { AuthCredentials } from '@nangohq/shared';
import type { PostPublicAppStoreAuthorization } from '@nangohq/types';
import { errorRestrictConnectionId, isIntegrationAllowed } from '../../utils/auth.js';

import type { NextFunction } from 'express';

const bodyValidation = z
Expand Down Expand Up @@ -101,7 +90,6 @@ export const postPublicAppStoreAuthorization = asyncWrapper<PostPublicAppStoreAu
},
{ account, environment }
);
void analytics.track(AnalyticsTypes.PRE_APP_STORE_AUTH, account.id);

if (!isConnectSession) {
const checked = await hmacCheck({ environment, logCtx, providerConfigKey, connectionId, hmac, res });
Expand Down Expand Up @@ -182,11 +170,9 @@ export const postPublicAppStoreAuthorization = asyncWrapper<PostPublicAppStoreAu
const [updatedConnection] = await connectionService.upsertConnection({
connectionId,
providerConfigKey,
provider: config.provider,
parsedRawCredentials: credentials as unknown as AuthCredentials,
connectionConfig,
environmentId: environment.id,
accountId: account.id
environmentId: environment.id
});
if (!updatedConnection) {
res.status(500).send({ error: { code: 'server_error', message: 'failed to create connection' } });
Expand Down
6 changes: 1 addition & 5 deletions packages/server/lib/controllers/auth/postBasic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { z } from 'zod';
import db from '@nangohq/database';
import { defaultOperationExpiration, endUserToMeta, logContextGetter } from '@nangohq/logs';
import {
AnalyticsTypes,
ErrorSourceEnum,
LogActionEnum,
analytics,
configService,
connectionService,
errorManager,
Expand Down Expand Up @@ -102,7 +100,6 @@ export const postPublicBasicAuthorization = asyncWrapper<PostPublicBasicAuthoriz
},
{ account, environment }
);
void analytics.track(AnalyticsTypes.PRE_BASIC_API_KEY_AUTH, account.id);

if (!isConnectSession) {
const checked = await hmacCheck({ environment, logCtx, providerConfigKey, connectionId, hmac, res });
Expand Down Expand Up @@ -174,8 +171,7 @@ export const postPublicBasicAuthorization = asyncWrapper<PostPublicBasicAuthoriz
connectionConfig,
metadata: {},
config,
environment,
account
environment
});
if (!updatedConnection) {
res.status(500).send({ error: { code: 'server_error', message: 'failed to create connection' } });
Expand Down
6 changes: 1 addition & 5 deletions packages/server/lib/controllers/auth/postBill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { z } from 'zod';
import db from '@nangohq/database';
import { defaultOperationExpiration, endUserToMeta, logContextGetter } from '@nangohq/logs';
import {
AnalyticsTypes,
ErrorSourceEnum,
LogActionEnum,
analytics,
billClient,
configService,
connectionService,
Expand Down Expand Up @@ -103,7 +101,6 @@ export const postPublicBillAuthorization = asyncWrapper<PostPublicBillAuthorizat
},
{ account, environment }
);
void analytics.track(AnalyticsTypes.PRE_BILL_AUTH, account.id);

if (!isConnectSession) {
const checked = await hmacCheck({ environment, logCtx, providerConfigKey, connectionId, hmac, res });
Expand Down Expand Up @@ -168,8 +165,7 @@ export const postPublicBillAuthorization = asyncWrapper<PostPublicBillAuthorizat
connectionConfig,
metadata: {},
config,
environment,
account
environment
});
if (!updatedConnection) {
res.status(500).send({ error: { code: 'server_error', message: 'failed to create connection' } });
Expand Down
6 changes: 1 addition & 5 deletions packages/server/lib/controllers/auth/postJwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { z } from 'zod';
import db from '@nangohq/database';
import { defaultOperationExpiration, endUserToMeta, logContextGetter } from '@nangohq/logs';
import {
AnalyticsTypes,
ErrorSourceEnum,
LogActionEnum,
analytics,
configService,
connectionService,
errorManager,
Expand Down Expand Up @@ -99,7 +97,6 @@ export const postPublicJwtAuthorization = asyncWrapper<PostPublicJwtAuthorizatio
},
{ account, environment }
);
void analytics.track(AnalyticsTypes.PRE_JWT_AUTH, account.id);

if (!isConnectSession) {
const checked = await hmacCheck({ environment, logCtx, providerConfigKey, connectionId, hmac, res });
Expand Down Expand Up @@ -177,8 +174,7 @@ export const postPublicJwtAuthorization = asyncWrapper<PostPublicJwtAuthorizatio
connectionConfig,
metadata: {},
config,
environment,
account
environment
});
if (!updatedConnection) {
res.status(500).send({ error: { code: 'server_error', message: 'failed to create connection' } });
Expand Down
6 changes: 1 addition & 5 deletions packages/server/lib/controllers/auth/postSignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { z } from 'zod';
import db from '@nangohq/database';
import { defaultOperationExpiration, endUserToMeta, logContextGetter } from '@nangohq/logs';
import {
AnalyticsTypes,
ErrorSourceEnum,
LogActionEnum,
analytics,
configService,
connectionService,
errorManager,
Expand Down Expand Up @@ -105,7 +103,6 @@ export const postPublicSignatureAuthorization = asyncWrapper<PostPublicSignature
},
{ account, environment }
);
void analytics.track(AnalyticsTypes.PRE_SIGNATURE_AUTH, account.id);

if (!isConnectSession) {
const checked = await hmacCheck({ environment, logCtx, providerConfigKey, connectionId, hmac, res });
Expand Down Expand Up @@ -183,8 +180,7 @@ export const postPublicSignatureAuthorization = asyncWrapper<PostPublicSignature
connectionConfig,
metadata: {},
config,
environment,
account
environment
});
if (!updatedConnection) {
res.status(500).send({ error: { code: 'server_error', message: 'failed to create connection' } });
Expand Down
6 changes: 1 addition & 5 deletions packages/server/lib/controllers/auth/postTableau.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { z } from 'zod';
import db from '@nangohq/database';
import { defaultOperationExpiration, endUserToMeta, logContextGetter } from '@nangohq/logs';
import {
AnalyticsTypes,
ErrorSourceEnum,
LogActionEnum,
analytics,
configService,
connectionService,
errorManager,
Expand Down Expand Up @@ -102,7 +100,6 @@ export const postPublicTableauAuthorization = asyncWrapper<PostPublicTableauAuth
},
{ account, environment }
);
void analytics.track(AnalyticsTypes.PRE_TBA_AUTH, account.id);

if (!isConnectSession) {
const checked = await hmacCheck({ environment, logCtx, providerConfigKey, connectionId, hmac, res });
Expand Down Expand Up @@ -175,8 +172,7 @@ export const postPublicTableauAuthorization = asyncWrapper<PostPublicTableauAuth
connectionConfig,
metadata: {},
config,
environment,
account
environment
});
if (!updatedConnection) {
res.status(500).send({ error: { code: 'server_error', message: 'failed to create connection' } });
Expand Down
6 changes: 1 addition & 5 deletions packages/server/lib/controllers/auth/postTba.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { z } from 'zod';
import db from '@nangohq/database';
import { defaultOperationExpiration, endUserToMeta, logContextGetter } from '@nangohq/logs';
import {
AnalyticsTypes,
ErrorSourceEnum,
LogActionEnum,
analytics,
configService,
connectionService,
errorManager,
Expand Down Expand Up @@ -107,7 +105,6 @@ export const postPublicTbaAuthorization = asyncWrapper<PostPublicTbaAuthorizatio
},
{ account, environment }
);
void analytics.track(AnalyticsTypes.PRE_TBA_AUTH, account.id);

if (!isConnectSession) {
const checked = await hmacCheck({ environment, logCtx, providerConfigKey, connectionId, hmac, res });
Expand Down Expand Up @@ -208,8 +205,7 @@ export const postPublicTbaAuthorization = asyncWrapper<PostPublicTbaAuthorizatio
},
metadata: {},
config,
environment,
account
environment
});
if (!updatedConnection) {
res.status(500).send({ error: { code: 'server_error', message: 'failed to create connection' } });
Expand Down
6 changes: 1 addition & 5 deletions packages/server/lib/controllers/auth/postTwoStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import { z } from 'zod';
import db from '@nangohq/database';
import { defaultOperationExpiration, endUserToMeta, logContextGetter } from '@nangohq/logs';
import {
AnalyticsTypes,
ErrorSourceEnum,
LogActionEnum,
analytics,
configService,
connectionService,
errorManager,
Expand Down Expand Up @@ -96,7 +94,6 @@ export const postPublicTwoStepAuthorization = asyncWrapper<PostPublicTwoStepAuth
},
{ account, environment }
);
void analytics.track(AnalyticsTypes.PRE_TWO_STEP_AUTH, account.id);

if (!isConnectSession) {
const checked = await hmacCheck({ environment, logCtx, providerConfigKey, connectionId, hmac, res });
Expand Down Expand Up @@ -175,8 +172,7 @@ export const postPublicTwoStepAuthorization = asyncWrapper<PostPublicTwoStepAuth
connectionConfig,
metadata: {},
config,
environment,
account
environment
});

if (!updatedConnection) {
Expand Down
7 changes: 2 additions & 5 deletions packages/server/lib/controllers/auth/postUnauthenticated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from 'zod';

import db from '@nangohq/database';
import { defaultOperationExpiration, endUserToMeta, logContextGetter } from '@nangohq/logs';
import { AnalyticsTypes, analytics, configService, connectionService, errorManager, getConnectionConfig, getProvider, linkConnection } from '@nangohq/shared';
import { configService, connectionService, errorManager, getConnectionConfig, getProvider, linkConnection } from '@nangohq/shared';
import { metrics, requireEmptyBody, stringifyError, zodErrorToHTTP } from '@nangohq/utils';

import { connectionCredential, connectionIdSchema, providerConfigKeySchema } from '../../helpers/validation.js';
Expand Down Expand Up @@ -73,7 +73,6 @@ export const postPublicUnauthenticated = asyncWrapper<PostPublicUnauthenticatedA
},
{ account, environment }
);
void analytics.track(AnalyticsTypes.PRE_UNAUTH, account.id);

if (!isConnectSession) {
const checked = await hmacCheck({ environment, logCtx, providerConfigKey, connectionId, hmac, res });
Expand Down Expand Up @@ -126,10 +125,8 @@ export const postPublicUnauthenticated = asyncWrapper<PostPublicUnauthenticatedA
const [updatedConnection] = await connectionService.upsertUnauthConnection({
connectionId,
providerConfigKey,
provider: config.provider,
connectionConfig,
environment,
account
environment
});

if (!updatedConnection) {
Expand Down
Loading
Loading