Skip to content

Commit

Permalink
feat: cookie token (#8057)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Onnikov <[email protected]>
  • Loading branch information
aonnikov authored Feb 24, 2025
1 parent b917356 commit 20bbe82
Show file tree
Hide file tree
Showing 65 changed files with 1,136 additions and 958 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ jobs:
DOCKER_CLI_HINTS: false
- name: Configure /etc/hosts
run: |
sudo echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts
sudo echo "127.0.0.1 huly.local" | sudo tee -a /etc/hosts
- name: Prepare server
run: |
cd ./qms-tests
Expand Down Expand Up @@ -479,7 +479,7 @@ jobs:
DOCKER_CLI_HINTS: false
- name: Configure /etc/hosts
run: |
sudo echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts
sudo echo "127.0.0.1 huly.local" | sudo tee -a /etc/hosts
- name: Prepare server
run: |
cd ./ws-tests
Expand Down
38 changes: 19 additions & 19 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"args": ["src/__start.ts"],
"env": {
// "FULLTEXT_URL": "http://localhost:4700",
"FULLTEXT_URL": "http://host.docker.internal:4702",
"FULLTEXT_URL": "http://huly.local:4702",
// "MONGO_URL": "mongodb://localhost:27017",
// "DB_URL": "mongodb://localhost:27017",
// "DB_URL": "postgresql://postgres:example@localhost:5432",
"DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable",
"GREEN_URL": "http://host.docker.internal:6767?token=secret",
"DB_URL": "postgresql://root@huly.local:26257/defaultdb?sslmode=disable",
"GREEN_URL": "http://huly.local:6767?token=secret",
"SERVER_PORT": "3332",
"APM_SERVER_URL2": "http://localhost:8200",
"METRICS_CONSOLE": "false",
Expand All @@ -60,7 +60,7 @@
"ELASTIC_INDEX_NAME": "local_storage_index",
"UPLOAD_URL": "/files",
"AI_BOT_URL": "http://localhost:4010",
"STATS_URL": "http://host.docker.internal:4900"
"STATS_URL": "http://huly.local:4900"
},
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeVersion": "20",
Expand All @@ -79,8 +79,8 @@
"FULLTEXT_URL": "http://localhost:4710",
// "DB_URL": "mongodb://localhost:27018",
// "DB_URL": "postgresql://postgres:example@localhost:5432",
"DB_URL": "postgresql://root@host.docker.internal:26258/defaultdb?sslmode=disable",
// "GREEN_URL": "http://host.docker.internal:6767?token=secret",
"DB_URL": "postgresql://root@huly.local:26258/defaultdb?sslmode=disable",
// "GREEN_URL": "http://huly.local:6767?token=secret",
"SERVER_PORT": "3335",
"METRICS_CONSOLE": "false",
"METRICS_FILE": "${workspaceRoot}/metrics.txt", // Show metrics in console evert 30 seconds.,
Expand All @@ -92,7 +92,7 @@
"ACCOUNTS_URL": "http://localhost:3003",
"MODEL_JSON": "${workspaceRoot}/models/all/bundle/model.json",
"MODEL_VERSION": "0.7.1",
"STATS_URL": "http://host.docker.internal:4901"
"STATS_URL": "http://huly.local:4901"
},
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"runtimeVersion": "20",
Expand All @@ -113,13 +113,13 @@
"FULLTEXT_DB_URL": "http://localhost:9200",
// "DB_URL": "mongodb://localhost:27017",
// "DB_URL": "postgresql://postgres:example@localhost:5432",
"DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable",
"DB_URL": "postgresql://root@huly.local:26257/defaultdb?sslmode=disable",
"STORAGE_CONFIG": "minio|localhost?accessKey=minioadmin&secretKey=minioadmin",
"SERVER_SECRET": "secret",
"REKONI_URL": "http://localhost:4004",
"MODEL_JSON": "${workspaceRoot}/models/all/bundle/model.json",
"ELASTIC_INDEX_NAME": "local_storage_index",
"STATS_URL":"http://host.docker.internal:4900",
"STATS_URL":"http://huly.local:4900",
"ACCOUNTS_URL": "http://localhost:3000",
},
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
Expand All @@ -138,14 +138,14 @@
"env": {
"MONGO_URL": "mongodb://localhost:27017",
"DB_URL": "mongodb://localhost:27017",
// "DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable",
// "DB_URL": "postgresql://root@huly.local:26257/defaultdb?sslmode=disable",
"SERVER_SECRET": "secret",
"REGION_INFO":"|Mongo;cockroach|CockroachDB",
"TRANSACTOR_URL": "ws://host.docker.internal:3333,ws://host.docker.internal:3332;;cockroach",
"TRANSACTOR_URL": "ws://huly.local:3333,ws://huly.local:3332;;cockroach",
"ACCOUNTS_URL": "http://localhost:3000",
"ACCOUNT_PORT": "3000",
"FRONT_URL": "http://localhost:8080",
"STATS_URL": "http://host.docker.internal:4900",
"STATS_URL": "http://huly.local:4900",
"SES_URL": "",
// "DB_NS": "account-2",
// "WS_LIVENESS_DAYS": "1",
Expand All @@ -172,11 +172,11 @@
// "DB_URL": "postgresql://postgres:example@localhost:5432",
"SERVER_SECRET": "secret",
"REGION_INFO":"|Mongo;pg|Postgres;cockroach|CockroachDB",
"TRANSACTOR_URL": "ws://host.docker.internal:3334;;,ws://host.docker.internal:3335;;europe",
"TRANSACTOR_URL": "ws://huly.local:3334;;,ws://huly.local:3335;;europe",
"ACCOUNTS_URL": "http://localhost:3003",
"ACCOUNT_PORT": "3003",
"FRONT_URL": "http://localhost:8083",
"STATS_URL": "http://host.docker.internal:4901",
"STATS_URL": "http://huly.local:4901",
"SES_URL": "",
// "DB_NS": "account-2",
// "WS_LIVENESS_DAYS": "1",
Expand Down Expand Up @@ -216,7 +216,7 @@
"env": {
"DB_URL": "mongodb://localhost:27017",
// "DB_URL": "postgresql://postgres:example@localhost:5432",
// "DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable",
// "DB_URL": "postgresql://root@huly.local:26257/defaultdb?sslmode=disable",

"REGION": "",
"SERVER_SECRET": "secret",
Expand Down Expand Up @@ -249,8 +249,8 @@
"env": {
// "DB_URL": "mongodb://localhost:27017",
// "DB_URL": "postgresql://postgres:example@localhost:5432",
"DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable",
"FULLTEXT_URL": "http://host.docker.internal:4702",
"DB_URL": "postgresql://root@huly.local:26257/defaultdb?sslmode=disable",
"FULLTEXT_URL": "http://huly.local:4702",
"REGION": "cockroach",
"SERVER_SECRET": "secret",
"TRANSACTOR_URL": "ws://localhost:3332",
Expand Down Expand Up @@ -415,7 +415,7 @@
"ACCOUNT_DB_URL": "mongodb://localhost:27017",
// "ACCOUNT_DB_URL": "postgresql://postgres:example@localhost:5433",
// "DB_URL": "postgresql://postgres:example@localhost:5433",
"DB_URL": "postgresql://root@host.docker.internal:26257/defaultdb?sslmode=disable",
"DB_URL": "postgresql://root@huly.local:26257/defaultdb?sslmode=disable",
"MONGO_URL": "mongodb://localhost:27017",
"TELEGRAM_DATABASE": "telegram-service",
"REKONI_URL": "http://localhost:4004",
Expand Down Expand Up @@ -514,7 +514,7 @@
"PLATFORM_OPERATION_LOGGING": "true",
"FRONT_URL": "http://localhost:8080",
"PORT": "3500",
"STATS_URL": "http://host.docker.internal:4900"
"STATS_URL": "http://huly.local:4900"
},
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"sourceMaps": true,
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ This project offers a convenient method to host Huly using `docker`, designed fo
- [Table of Content](#table-of-content)
- [Pre-requisites](#pre-requisites)
- [Verification](#verification)
- [Fast start](#fast-start)
- [Branches \& Contributing](#branches--contributing)
- [Installation](#installation)
- [Build and run](#build-and-run)
- [Run in development mode](#run-in-development-mode)
Expand Down Expand Up @@ -149,10 +151,10 @@ sh ./scripts/create-workspace.sh
Add the following line to your /etc/hosts file

```plain
127.0.0.1 host.docker.internal
127.0.0.1 huly.local
```

Accessing the URL <http://host.docker.internal:8087> will lead you to the app in development mode.
Accessing the URL <http://huly.local:8087> will lead you to the app in development mode.

Limitations:

Expand Down
10 changes: 9 additions & 1 deletion common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion desktop/.env-dev
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
FRONT_URL=http://localhost:8087
FRONT_URL=http://huly.local:8087
CONFIG_URL=config.json
2 changes: 1 addition & 1 deletion desktop/src/main/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const serverChanged = oldFront !== FRONT_URL

function readServerUrl (): string {
if (isDev) {
return process.env.FRONT_URL ?? 'http://localhost:8087'
return process.env.FRONT_URL ?? 'http://huly.local:8087'
}

return ((settings as any).get('server', process.env.FRONT_URL) as string) ?? 'https://huly.app'
Expand Down
24 changes: 5 additions & 19 deletions desktop/src/ui/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import login, { loginId } from '@hcengineering/login'
import { getEmbeddedLabel, getMetadata, setMetadata } from '@hcengineering/platform'
import presentation, { closeClient, MessageBox, setDownloadProgress } from '@hcengineering/presentation'
import { loginId } from '@hcengineering/login'
import { getEmbeddedLabel, getMetadata } from '@hcengineering/platform'
import presentation, { MessageBox, setDownloadProgress } from '@hcengineering/presentation'
import settings, { settingId } from '@hcengineering/setting'
import {
closePanel,
closePopup,
createApp,
fetchMetadataLocalStorage,
getCurrentLocation,
getCurrentResolvedLocation,
navigate,
parseLocation,
pushRootBarProgressComponent,
removeRootBarComponent,
setMetadataLocalStorage,
showPopup
} from '@hcengineering/ui'

import { notificationId } from '@hcengineering/notification'
import { workbenchId } from '@hcengineering/workbench'
import { workbenchId, logOut } from '@hcengineering/workbench'

import { isOwnerOrMaintainer } from '@hcengineering/core'
import { configurePlatform } from './platform'
Expand Down Expand Up @@ -58,18 +55,7 @@ window.addEventListener('DOMContentLoaded', () => {
})

ipcMain.on('logout', () => {
const tokens = fetchMetadataLocalStorage(login.metadata.LoginTokensV2)
if (tokens !== null) {
const loc = getCurrentLocation()
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete tokens[loc.path[1]]
setMetadataLocalStorage(login.metadata.LoginTokensV2, tokens)
}
setMetadata(presentation.metadata.Token, null)
setMetadataLocalStorage(login.metadata.LastToken, null)
setMetadataLocalStorage(login.metadata.LoginEndpoint, null)
setMetadataLocalStorage(login.metadata.LoginAccount, null)
void closeClient().then(() => {
void logOut().then(() => {
navigate({ path: [loginId] })
})
})
Expand Down
8 changes: 4 additions & 4 deletions dev/branding.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"localhost:8080": {
"huly.local:8080": {
"key": "huly-dev",
"title": "Huly",
"protocol": "http",
"language": "en",
"lastNameFirst": "true"
},
"localhost:8087": {
"huly.local:8087": {
"key": "huly",
"title": "Huly",
"protocol": "http",
Expand All @@ -20,13 +20,13 @@
"language": "en",
"lastNameFirst": "true"
},
"localhost:8081": {
"huly.local:8081": {
"key": "tracex-dev",
"title": "TraceX",
"protocol": "http",
"language": "en"
},
"localhost:8088": {
"huly.local:8088": {
"key": "tracex",
"title": "TraceX",
"protocol": "http",
Expand Down
Loading

0 comments on commit 20bbe82

Please sign in to comment.