Skip to content

Commit 4cdbe49

Browse files
Merge pull request #2202 from RedisInsight/be/feature/RI-4454_Restrict_loopback
#RI-4454 - Restrict loopback
2 parents c437700 + d0a5156 commit 4cdbe49

27 files changed

+222
-24
lines changed

configs/webpack.config.renderer.prod.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ const devtoolsConfig =
2323
const configuration: webpack.Configuration = {
2424
...devtoolsConfig,
2525

26-
devtool: 'source-map',
27-
2826
mode: 'production',
2927

3028
target: ['web', 'electron-renderer'],

configs/webpack.config.renderer.stage.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ DeleteSourceMaps();
1010
export default merge(baseConfig, {
1111
...rendererProdConfig,
1212

13+
devtool: 'source-map',
14+
1315
plugins: [
1416
...rendererProdConfig.plugins,
1517

redisinsight/api/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"format": "prettier --write \"src/**/*.ts\"",
2222
"lint": "eslint --ext .ts .",
2323
"start": "nest start",
24-
"start:dev": "cross-env NODE_ENV=development SERVER_STATIC_CONTENT=1 nest start --watch",
24+
"start:dev": "cross-env NODE_ENV=development BUILD_TYPE=DOCKER_ON_PREMISE SERVER_STATIC_CONTENT=1 nest start --watch",
2525
"start:debug": "nest start --debug --watch",
2626
"start:stage": "cross-env NODE_ENV=staging SERVER_STATIC_CONTENT=true node dist/src/main",
2727
"start:prod": "cross-env NODE_ENV=production node dist/src/main",
@@ -32,8 +32,8 @@
3232
"test:e2e": "jest --config ./test/jest-e2e.json -w 1",
3333
"typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d ./config/ormconfig.ts",
3434
"test:api": "cross-env NODE_ENV=test ts-mocha --paths -p test/api/api.tsconfig.json --config ./test/api/.mocharc.yml",
35-
"test:api:cov": "nyc --reporter=html --reporter=text --reporter=text-summary yarn run test:api",
36-
"test:api:ci:cov": "nyc -r text -r text-summary -r html yarn run test:api --reporter mocha-multi-reporters --reporter-options configFile=test/api/reporters.json && nyc merge .nyc_output ./coverage/test-run-coverage.json",
35+
"test:api:cov": "cross-env BUILD_TYPE=DOCKER_ON_PREMISE nyc --reporter=html --reporter=text --reporter=text-summary yarn run test:api",
36+
"test:api:ci:cov": "cross-env BUILD_TYPE=DOCKER_ON_PREMISE nyc -r text -r text-summary -r html yarn run test:api --reporter mocha-multi-reporters --reporter-options configFile=test/api/reporters.json && nyc merge .nyc_output ./coverage/test-run-coverage.json",
3737
"typeorm:migrate": "cross-env NODE_ENV=staging yarn typeorm migration:generate ./migration/migration",
3838
"typeorm:run": "yarn typeorm migration:run"
3939
},
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const API_PARAM_DATABASE_ID = 'dbInstance';
22
export const API_HEADER_DATABASE_INDEX = 'ri-db-index';
3+
export const API_HEADER_WINDOW_ID = 'x-window-id';
34
export const API_PARAM_CLI_CLIENT_ID = 'uuid';
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export enum CustomErrorCodes {
2+
WindowUnauthorized = 10_001,
3+
}

redisinsight/api/src/constants/error-messages.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,6 @@ export default {
6464
APP_SETTINGS_NOT_FOUND: () => 'Could not find application settings.',
6565
SERVER_INFO_NOT_FOUND: () => 'Could not find server info.',
6666
INCREASE_MINIMUM_LIMIT: (count: string) => `Set MAXSEARCHRESULTS to at least ${count}.`,
67+
INVALID_WINDOW_ID: 'Invalid window id.',
68+
UNDEFINED_WINDOW_ID: 'Undefined window id.',
6769
};

redisinsight/api/src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ export * from './telemetry-events';
1010
export * from './app-events';
1111
export * from './redis-connection';
1212
export * from './recommendations';
13+
export * from './custom-error-codes';

redisinsight/api/src/core.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { AnalyticsModule } from 'src/modules/analytics/analytics.module';
1010
import { SshModule } from 'src/modules/ssh/ssh.module';
1111
import { NestjsFormDataModule } from 'nestjs-form-data';
1212
import { FeatureModule } from 'src/modules/feature/feature.module';
13+
import { AuthModule } from 'src/modules/auth/auth.module';
1314

1415
@Global()
1516
@Module({
@@ -25,6 +26,7 @@ import { FeatureModule } from 'src/modules/feature/feature.module';
2526
SshModule,
2627
NestjsFormDataModule,
2728
FeatureModule.register(),
29+
AuthModule.register(),
2830
],
2931
exports: [
3032
EncryptionModule,

redisinsight/api/src/main.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'dotenv/config';
22
import { NestFactory } from '@nestjs/core';
33
import { SwaggerModule } from '@nestjs/swagger';
4-
import { NestApplicationOptions } from '@nestjs/common';
4+
import { INestApplication, NestApplicationOptions } from '@nestjs/common';
55
import * as bodyParser from 'body-parser';
66
import { WinstonModule } from 'nest-winston';
77
import { GlobalExceptionFilter } from 'src/exceptions/global-exception.filter';
@@ -14,7 +14,12 @@ import LOGGER_CONFIG from '../config/logger';
1414

1515
const serverConfig = get('server');
1616

17-
export default async function bootstrap(): Promise<Function> {
17+
interface IApp {
18+
app: INestApplication
19+
gracefulShutdown: Function
20+
}
21+
22+
export default async function bootstrap(): Promise<IApp> {
1823
await migrateHomeFolder();
1924

2025
const port = process.env.API_PORT || serverConfig.port;
@@ -67,7 +72,7 @@ export default async function bootstrap(): Promise<Function> {
6772
process.on('SIGTERM', gracefulShutdown);
6873
process.on('SIGINT', gracefulShutdown);
6974

70-
return gracefulShutdown;
75+
return { app, gracefulShutdown };
7176
}
7277

7378
if (process.env.APP_ENV !== 'electron') {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Module } from '@nestjs/common';
2+
import config from 'src/utils/config';
3+
import { WindowAuthModule } from './window-auth/window-auth.module';
4+
import { BuildType } from '../server/models/server';
5+
6+
const SERVER_CONFIG = config.get('server');
7+
8+
@Module({})
9+
export class AuthModule {
10+
static register() {
11+
const imports = [];
12+
13+
if (SERVER_CONFIG.buildType === BuildType.Electron) {
14+
imports.push(WindowAuthModule);
15+
}
16+
17+
return {
18+
module: AuthModule,
19+
imports,
20+
};
21+
}
22+
}

0 commit comments

Comments
 (0)