Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
e27cef8
Change the wording on the native browser authentication page
Oct 16, 2024
8b6c1b0
RI-5876-Fix start electron dev mode
Oct 24, 2024
eedcbf0
RI-5876 Fix start electron dev mode - cleanup
Oct 24, 2024
31b7f1d
RI-5876 Fix Electron in dev mode -> fix for window validation in dev …
Oct 25, 2024
4e0431d
RI-5876 Fix start electron dev mode - clean up and hardcoded values
Oct 25, 2024
e8b543b
RI-5876 fix start electron dev mode - fixed auth flow for dev with tcp
Oct 25, 2024
ca5afa5
RI-5876 Fix start electron dev mode - cleanup
Oct 25, 2024
58fc233
RI-5876 fix start electron dev - cleanup
Oct 25, 2024
e9f3ee8
RI-5876 fix electron dev mode - further cleanup and removal of
Oct 26, 2024
7c324cc
RI-5876
Oct 26, 2024
331b2d1
RI-5876 Fix start electron dev mode
Oct 26, 2024
da77e73
RI-5876 fix electron dev mode - removed hardcoded if statement
Oct 28, 2024
ca4fc09
RI-5876 fix electron dev mode - removed unused dependency
Oct 28, 2024
2e63fdf
Merge branch 'RI-5876-Fix-start-electron-dev-mode' of https://github.…
Oct 28, 2024
0d20c20
RI-5876 cleanup
Oct 28, 2024
b030c90
RI-5876 cleanup
Oct 28, 2024
531dda9
RI-5876 cleanup
Oct 28, 2024
3b22245
RI-5876 cleanup
Oct 28, 2024
4b790fe
RI-5876 - cleaned up console.logs
Oct 28, 2024
c9c9830
RI-5876 fixed eslint errors
Oct 28, 2024
dfdfb09
RI-6876 fixed api test (#4022)
KIvanow Oct 28, 2024
9e3beff
Ri 5876 fix start electron dev mode (#4023)
KIvanow Oct 28, 2024
5828d6e
RI-5876 resolved conflicts with main
Oct 29, 2024
8907bfc
RI-5876 removed the custom-tutorials submitted from testin
Oct 29, 2024
d333be4
RI-5876 yarn.lock updates
Oct 29, 2024
1ae2a2d
added a command to run api, ui and desktop at the same time
Oct 30, 2024
5f3c10b
Merge branch 'be/feature/RI-5876-Fix-start-electron-dev-mode' of http…
Oct 30, 2024
0fdce87
RI-5876 Renamed new command
Oct 30, 2024
d6e4446
RI-5876 updated postinstall scripts
Oct 30, 2024
e66af79
RI-5876 fixes around the build flow
Oct 31, 2024
cadefc5
fixes around the build
Oct 31, 2024
9d2ebd7
RI-5876 WIP (build works without window ids - bug)
Nov 5, 2024
343e31b
RI-5876 WIP build updates
Nov 5, 2024
65911e4
RI-5876 WIP builds
Nov 5, 2024
5af4903
RI-5876 rollback on some changes
KIvanow Nov 5, 2024
de314fc
resolved conflicts
KIvanow Nov 5, 2024
5ecc9ad
RI-5876 clean up
KIvanow Nov 5, 2024
c090347
RI-5876 cleanup
KIvanow Nov 5, 2024
e1a4c43
RI-5876 cleanup
KIvanow Nov 5, 2024
206cf00
RI-5876 cleanup
KIvanow Nov 5, 2024
2d8463e
RI-5876 cleanup
KIvanow Nov 5, 2024
f3e6efa
RI-5876 cleanup
Nov 6, 2024
a781d26
RI-5876 circular dependency solved
Nov 6, 2024
31a4722
RI-5876 resolved dependency and all changes
Nov 6, 2024
6568a27
RI-5876 clean up
Nov 6, 2024
9df3bd0
RI-5876 fixed wrong enum import
Nov 6, 2024
1efa61f
RI-5876 cleaning up the PR
Nov 6, 2024
d6c7c70
removed unused file
Nov 8, 2024
7b36fb6
RI-5876 cleanup unused variables
Nov 8, 2024
92b1d12
RI-5876 cleanedup electron-dev conig
Nov 8, 2024
b8eb6df
RI-5876 simplified electron-builder.dev
Nov 8, 2024
d3329e3
RI-5876 removed unused properties
Nov 8, 2024
998adee
RI-5876 removed unecesary differences
Nov 8, 2024
0e44625
RI-5876 cleared up feedback (process.env.development checks and unuse…
Nov 11, 2024
001df41
RI-5876 Cleared up PR feedback
Nov 11, 2024
5546292
Merge branch 'be/feature/RI-5876-Fix-start-electron-dev-mode' of http…
Nov 11, 2024
2f8b858
RI-5876 removed unused file
Nov 11, 2024
2c7b10d
RI-5876 - PR feedback from Artem
KIvanow Nov 19, 2024
c6c267f
Merge branch 'main' of https://github.com/RedisInsight/RedisInsight i…
KIvanow Nov 19, 2024
cc7eb9f
RI-6876 cleared up prettier issue
KIvanow Nov 19, 2024
b68f8fb
RI-5876 - feedback from Artem - abstraction for the TCP approach on d…
Nov 24, 2024
fb0e969
RI-5876 - further PR improvements and cleanup
Nov 24, 2024
d145e49
Merge branch 'main' of https://github.com/RedisInsight/RedisInsight i…
Nov 28, 2024
39cd861
reverted yarn.lock to main's
Nov 28, 2024
365a108
rollback to main
Nov 28, 2024
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
root: true,
env: {
node: true,
browser: true,
},
extends: ['airbnb-typescript'],
plugins: ['@typescript-eslint'],
Expand Down
15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
"license": "SSPL",
"private": true,
"scripts": {
"dev:ui": "yarn --cwd redisinsight/ui dev",
"dev:ui": "cross-env yarn --cwd redisinsight/ui dev",
"dev:api": "cross-env yarn --cwd redisinsight/api start:dev",
"dev:electron:ui": "cross-env RI_APP_PORT=8080 RI_APP_TYPE=electron NODE_ENV=development yarn --cwd redisinsight/ui dev",
"dev:electron:api": "cross-env RI_APP_PORT=5540 RI_APP_TYPE=electron NODE_ENV=development USE_TCP_CLOUD_AUTH=true yarn --cwd redisinsight/api start:dev",
"dev:electron": "cross-env RI_APP_TYPE=electron RI_AUTO_BOOTSTRAP=false NODE_ENV=development USE_TCP_CLOUD_AUTH=true yarn --cwd redisinsight/desktop dev",
"dev:desktop": "concurrently \"yarn dev:electron:api\" \"yarn dev:electron:ui\" \"yarn dev:electron\"",
"build:ui": "cross-env NODE_ENV=production RI_APP_TYPE=web yarn --cwd redisinsight/ui build",
"build:renderer": "cross-env NODE_ENV=production RI_APP_TYPE=electron yarn --cwd redisinsight/ui build --emptyOutDir && copyfiles ./redisinsight/desktop/splash.html ./redisinsight/dist/renderer -f",
"stats:ui": "yarn --cwd redisinsight/ui stats",
Expand All @@ -23,6 +28,7 @@
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:ui": "eslint ./redisinsight/ui --ext .js,.jsx,.ts,.tsx",
"lint:api": "yarn --cwd redisinsight/api lint",
"lint:desktop": "eslint ./redisinsight/desktop",
"lint:e2e": "yarn --cwd tests/e2e lint",
"package": "yarn package:dev",
"package:prod": "ts-node ./scripts/prebuild.js dist && yarn build:prod && electron-builder build -p never",
Expand All @@ -34,8 +40,10 @@
"package:mac": "yarn build:prod && electron-builder build --mac -p never",
"package:mac:arm": "yarn build:prod && electron-builder build --mac --arm64 -p never",
"package:linux": "yarn build:prod && electron-builder build --linux -p never",
"postinstall": "patch-package && vite optimize && skip-postinstall || (electron-builder install-app-deps && yarn-deduplicate yarn.lock)",
"postinstall": "patch-package && vite optimize -c ./redisinsight/ui/vite.config.mjs && skip-postinstall || (electron-builder install-app-deps && yarn-deduplicate yarn.lock)",
"test": "jest ./redisinsight/ui -w 1",
"test:api": "yarn --cwd redisinsight/api test",
"test:api:integration": "yarn --cwd redisinsight/api test:api",
"test:watch": "jest ./redisinsight/ui --watch -w 1",
"test:cov": "cross-env NODE_OPTIONS='' jest ./redisinsight/ui --silent --coverage --no-cache --forceExit -w 3",
"test:cov:unit": "jest ./redisinsight/ui --group=-component --coverage -w 1",
Expand Down Expand Up @@ -244,6 +252,7 @@
"monaco-editor": "^0.48.0",
"monaco-yaml": "^5.1.1",
"msgpackr": "^1.10.1",
"node-abi": "^3.71.0",
"pako": "^2.1.0",
"php-serialize": "^4.0.2",
"pickleparser": "^0.2.1",
Expand Down Expand Up @@ -280,4 +289,4 @@
"browser": {
"uuid": "./node_modules/uuid/dist/esm-browser/index.js"
}
}
}
2 changes: 1 addition & 1 deletion redisinsight/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default async function bootstrap(apiPort?: number): Promise<IApp> {
app.use(bodyParser.urlencoded({ limit: '512mb', extended: true }));
app.enableCors();

if (process.env.RI_APP_TYPE !== 'electron') {
if (process.env.RI_APP_TYPE !== 'electron' || process.env.NODE_ENV === 'development') {
let prefix = serverConfig.globalPrefix;
if (serverConfig.proxyPath) {
prefix = posix.join(serverConfig.proxyPath, prefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import ERROR_MESSAGES from 'src/constants/error-messages';
import { API_HEADER_WINDOW_ID } from 'src/common/constants';
import { WindowAuthService } from '../window-auth.service';
import { WindowUnauthorizedException } from '../constants/exceptions';
import config from 'src/utils/config';

@Injectable()
export class WindowAuthMiddleware implements NestMiddleware {
private logger = new Logger('WindowAuthMiddleware');

constructor(private windowAuthService: WindowAuthService) {}

async use(req: Request, res: Response, next: NextFunction): Promise<any> {
const { windowId } = WindowAuthMiddleware.getWindowIdFromReq(req);

const isAuthorized = await this.windowAuthService.isAuthorized(windowId);

if (!isAuthorized) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ export class WindowAuthModule implements NestModule {
.exclude(...SERVER_CONFIG.excludeAuthRoutes)
.forRoutes('*');
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { Injectable, Logger } from '@nestjs/common';
import { createServer, Server } from 'net';
import { CloudAuthStrategy } from './cloud-auth.strategy';
import { CloudAuthService } from '../cloud-auth.service';

@Injectable()
export class TcpCloudAuthStrategy extends CloudAuthStrategy {
private authPort = process.env.TCP_LOCAL_CLOUD_AUTH_PORT ? parseInt(process.env.TCP_LOCAL_CLOUD_AUTH_PORT) : 5542;
private server: Server;
private readonly logger = new Logger('TcpCloudAuthStrategy');

constructor(private readonly cloudAuthService: CloudAuthService) {
super();

this.initServer();
}

private initServer() {
this.server = createServer((socket) => {
socket.setEncoding('utf8');

socket.on('data', async (data) => {
try {
this.logger.debug(`Received raw data: ${data.toString()}`);
const { action, options } = JSON.parse(data.toString());
this.logger.debug('Parsed request:', { action, options });

if (action === 'getAuthUrl') {
try {
const url = await this.cloudAuthService.getAuthorizationUrl(
options.sessionMetadata,
options.authOptions
);
this.logger.debug('Generated URL:', url);
socket.write(JSON.stringify({ success: true, url }));
} catch (err) {
this.logger.error('Error getting authorization URL:', err);
socket.write(JSON.stringify({
success: false,
error: err.message,
details: err.stack,
context: { action, options } // Add the context to help debug
}));
}
} else if (action === 'handleCallback') {
try {
this.logger.debug('Handling callback with query:', options.query);
const result = await this.cloudAuthService.handleCallback(options.query);
socket.write(JSON.stringify({ success: true, result }));
} catch (err) {
this.logger.error('Error handling callback:', err);
socket.write(JSON.stringify({
success: false,
error: err.message,
details: err.stack
}));
}
}
} catch (err) {
this.logger.error('Error processing request:', err);
socket.write(JSON.stringify({
success: false,
error: err.message,
details: err.stack
}));
}
socket.end();
});

socket.on('end', () => {
this.logger.debug('Client connection ended');
});

socket.on('error', (err) => {
this.logger.error('Socket error:', err);
});
});

this.server.listen(this.authPort, () => {
this.logger.log(`TCP server listening on port ${this.authPort}`);
});

this.server.on('error', (err) => {
this.logger.error('Server error:', err);
});
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has been resolved since :)

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SsoIdpCloudAuthStrategy } from 'src/modules/cloud/auth/auth-strategy/ss
import { CloudAuthService } from 'src/modules/cloud/auth/cloud-auth.service';
import { CloudAuthController } from 'src/modules/cloud/auth/cloud-auth.controller';
import { CloudAuthAnalytics } from 'src/modules/cloud/auth/cloud-auth.analytics';
import { TcpCloudAuthStrategy } from './auth-strategy/tcp-cloud.auth.strategy';

@Module({
imports: [CloudSessionModule],
Expand All @@ -15,8 +16,12 @@ import { CloudAuthAnalytics } from 'src/modules/cloud/auth/cloud-auth.analytics'
SsoIdpCloudAuthStrategy,
CloudAuthService,
CloudAuthAnalytics,
...(process.env.USE_TCP_CLOUD_AUTH === 'true' ? [TcpCloudAuthStrategy] : [])
],
controllers: [CloudAuthController],
exports: [CloudAuthService],
exports: [
CloudAuthService,
...(process.env.USE_TCP_CLOUD_AUTH === 'true' ? [TcpCloudAuthStrategy] : [])
],
})
export class CloudAuthModule {}
export class CloudAuthModule { }
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class CloudAuthService {
private readonly ssoIdpCloudAuthStrategy: SsoIdpCloudAuthStrategy,
private readonly analytics: CloudAuthAnalytics,
private readonly eventEmitter: EventEmitter2,
) {}
) { }

static getOAuthHttpRequestHeaders() {
return {
Expand All @@ -69,7 +69,7 @@ export class CloudAuthService {
) {
return (
authRequest?.idpType === CloudAuthIdpType.GitHub
&& query?.error_description?.indexOf('email') > -1
&& query?.error_description?.indexOf('email') > -1
)
? new CloudOauthGithubEmailPermissionException(query.error_description)
: new CloudOauthMissedRequiredDataException(query.error_description, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export class DatabaseRecommendationParams {
@IsRedisString({ each: true })
@RedisStringType({ each: true })
keys?: RedisString[];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,4 @@ export class DatabaseEntity {
@Expose()
@Column({ nullable: true })
version: string;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,4 @@ export class LocalDatabaseRepository extends DatabaseRepository {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ export class SshOptionsEntity {
)
@JoinColumn()
database: DatabaseEntity;
}
}
2 changes: 1 addition & 1 deletion redisinsight/api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9237,4 +9237,4 @@ yn@^2.0.0:
yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
10 changes: 0 additions & 10 deletions redisinsight/desktop/index.ejs

This file was deleted.

11 changes: 11 additions & 0 deletions redisinsight/desktop/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "redisinsight",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"dev": "cross-env ELECTRON_DEV=true ELECTRON_ENABLE_LOGGING=true ELECTRON_DEBUG_LOGGING=true ELECTRON_ENABLE_STACK_DUMPING=true NODE_ENV=development yarn build && yarn build:preload && yarn build:renderer && electron . --enable-logging --inspect=5858",
"build": "cross-env ELECTRON_DEV=true ELECTRON_ENABLE_LOGGING=true ELECTRON_DEBUG_LOGGING=true ELECTRON_ENABLE_STACK_DUMPING=true NODE_ENV=development vite build --config vite.main.config.ts",
"build:preload": "cross-env ELECTRON_DEV=true ELECTRON_ENABLE_LOGGING=true ELECTRON_DEBUG_LOGGING=true ELECTRON_ENABLE_STACK_DUMPING=true NODE_ENV=development vite build --config vite.preload.config.ts",
"build:renderer": "cross-env ELECTRON_DEV=true ELECTRON_ENABLE_LOGGING=true ELECTRON_DEBUG_LOGGING=true ELECTRON_ENABLE_STACK_DUMPING=true NODE_ENV=development vite build --config vite.renderer.config.ts"
}
}
2 changes: 1 addition & 1 deletion redisinsight/desktop/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ contextBridge.exposeInMainWorld('app', {
}
} as WindowApp)

export type IPCHandler = typeof ipcHandler
export type IPCHandler = typeof ipcHandler
4 changes: 3 additions & 1 deletion redisinsight/desktop/src/config/configMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import pkg from '../../../package.json'
const config: any = configInit

// Merge in some details from package.json
config.defaultPort = process.env.NODE_ENV === 'development' ? 5540 : config.defaultPort
config.name = pkg.appName
config.description = pkg.description
config.version = pkg.version
Expand All @@ -15,9 +16,10 @@ config.isDevelopment = process.env.NODE_ENV === 'development'
config.isProduction = process.env.NODE_ENV === 'production'
config.appPort = process.env.RI_APP_PORT || configInit.defaultPort
config.getApiPort = () => process.env.RI_APP_PORT || configInit.defaultPort
config.tcpLocalAuthPort = process.env.TCP_LOCAL_AUTH_PORT ? parseInt(process.env.TCP_LOCAL_AUTH_PORT, 10) : 5541

config.icon = getAssetPath('icon.png')

config.preloadPath = app.isPackaged ? path.join(__dirname, 'preload.js') : path.join(__dirname, '../../dll/preload.js')
config.preloadPath = app.isPackaged ? path.join(__dirname, 'preload.js') : path.join(__dirname, '../../../dist/preload.js')

export const configMain = config
1 change: 1 addition & 0 deletions redisinsight/desktop/src/config/configRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import pkg from '../../../package.json'
const config: any = configInit

// Merge in some details from package.json
config.defaultPort = process.env.NODE_ENV === 'development' ? 5540 : config.defaultPort
config.name = pkg.appName
config.description = pkg.description
config.version = pkg.version
Expand Down
14 changes: 14 additions & 0 deletions redisinsight/desktop/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
<title>RedisInsight</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="../dist/index.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion redisinsight/desktop/src/lib/app/deep-link.handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ export const deepLinkWindowHandler = async (parsedDeepLink?: IParsedDeepLink) =>
} else if (currentWindow) {
focusWindow(currentWindow)
}
}
}
12 changes: 12 additions & 0 deletions redisinsight/desktop/src/lib/auth/auth.factory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AuthStrategy } from './auth.interface'
import { TcpAuthStrategy } from './tcp.auth.strategy'
import { ServiceAuthStrategy } from './service.auth.strategy'

export const createAuthStrategy = (
beApp?: any
): AuthStrategy => {
if (process.env.USE_TCP_CLOUD_AUTH === 'true') {
return TcpAuthStrategy.getInstance()
}
return ServiceAuthStrategy.getInstance(beApp)
}
7 changes: 7 additions & 0 deletions redisinsight/desktop/src/lib/auth/auth.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export interface AuthStrategy {
initialize(): Promise<void>
shutdown(): Promise<void>
getAuthUrl(options: any): Promise<{ url: string }>
handleCallback(query: any): Promise<any>
getBackendApp?(): any
}
Loading
Loading