@eduwork/dsh-remote-access 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/LICENSE +130 -21
- package/LICENSE-MIT +21 -0
- package/LICENSING.md +17 -0
- package/README.md +4 -4
- package/README_EN.md +4 -4
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/docs/DEPLOYMENT.md +14 -6
- package/docs/DEPLOYMENT_EN.md +14 -6
- package/docs/docker/.dockerignore +4 -0
- package/docs/docker/Dockerfile +17 -0
- package/docs/docker/README.md +100 -0
- package/docs/docker/README_EN.md +100 -0
- package/docs/docker/compose.yaml +26 -0
- package/docs/docker/healthcheck.mjs +15 -0
- package/docs/docker/relay.env.example +16 -0
- package/lib/client.js +54 -54
- package/lib/index.js +290 -191
- package/lib/typert.js +5 -2
- package/package.json +16 -14
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Deploy the relay with Docker
|
|
2
|
+
|
|
3
|
+
[简体中文](README.md) · [Full deployment guide](../DEPLOYMENT_EN.md)
|
|
4
|
+
|
|
5
|
+
Use Docker Engine and Compose v2 to build a local image from the published `@eduwork/dsh-remote-access@0.1.2` npm package. The server needs neither a Node.js installation nor desktop files or plugin source. Prepare a domain and an HTTPS reverse proxy supporting WebSockets, then follow these steps.
|
|
6
|
+
|
|
7
|
+
## 1. Prepare files and configuration
|
|
8
|
+
|
|
9
|
+
Copy the deployment files from [this directory in the repository](https://github.com/ECNU/EduWork/tree/main/packages/dsh-remote-access/docs/docker) into one directory. To download them without cloning the repository, run this in a new, empty directory using a Linux shell:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
base=https://raw.githubusercontent.com/ECNU/EduWork/main/packages/dsh-remote-access/docs/docker
|
|
13
|
+
for file in Dockerfile compose.yaml healthcheck.mjs relay.env.example .dockerignore .gitignore; do
|
|
14
|
+
curl -fsSLo "$file" "$base/$file" || exit 1
|
|
15
|
+
done
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
With an existing checkout, enter `packages/dsh-remote-access/docs/docker`. Run the following commands from the directory containing the deployment files:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
cp relay.env.example relay.env
|
|
22
|
+
chmod 600 relay.env
|
|
23
|
+
docker run --rm node:24.22.1-alpine node -e "console.log(require('node:crypto').randomBytes(32).toString('base64url'))"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Edit `relay.env`, entering your public URL and the generated key:
|
|
27
|
+
|
|
28
|
+
```dotenv
|
|
29
|
+
RELAY_URL=https://example.edu/eduwork-remote/
|
|
30
|
+
RELAY_ACCESS_KEYS=replace-with-the-generated-random-key
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
A dedicated domain root also works, such as `https://remote.example.edu/`. Include any path prefix directly in `RELAY_URL`, ending with `/`; both the service and health check use it. The key admits computers to the relay; remote devices still require pairing approval on the computer.
|
|
34
|
+
|
|
35
|
+
The real `relay.env` is excluded from Git and the image build context. Do not share it as an attachment. The image installs the npm package during its build; startup reads environment configuration without accessing npm.
|
|
36
|
+
|
|
37
|
+
## 2. Start with one command
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
docker compose up -d --build
|
|
41
|
+
docker compose ps
|
|
42
|
+
docker compose logs --tail=100 relay
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The container runs as a non-root user with a read-only filesystem. Compose publishes **`127.0.0.1:8787` on the server**, for a reverse proxy on the same machine. Inside the container, `HOST=0.0.0.0` accepts Docker's port forwarding; do not change it to the container's loopback address.
|
|
46
|
+
|
|
47
|
+
Use the [Nginx configuration in the deployment guide](../DEPLOYMENT_EN.md#2-https-and-a-path-prefix) in your HTTPS site: forward to `http://127.0.0.1:8787`, preserving the prefix and WebSocket Upgrade. Configure certificates at the proxy; this Compose setup does not obtain certificates automatically.
|
|
48
|
+
|
|
49
|
+
If the proxy also runs in Docker, connect it to the relay's Docker network and use `http://relay:8787` as the upstream. A proxy container's `127.0.0.1` does not refer to the host. Adapt the upstream to your network topology.
|
|
50
|
+
|
|
51
|
+
## 3. Verify and connect a computer
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
docker compose exec -T relay node /opt/eduwork-remote/healthcheck.mjs
|
|
55
|
+
curl -fsS http://127.0.0.1:8787/eduwork-remote/healthz
|
|
56
|
+
curl -fsS https://example.edu/eduwork-remote/healthz
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The health check should succeed and both HTTP requests should return `ok`; omit `/eduwork-remote` for root deployments. Container health checks only the internal HTTP service. Verify external HTTPS, WebSockets and authentication from the desktop client as well.
|
|
60
|
+
|
|
61
|
+
With remote access plugin `0.1.2` installed, open Settings → Remote access, select your own relay, enter the same external URL and key, and choose "Test connection". It checks reachability and identity acceptance separately, even before remote access is enabled. Enable "Allow remote access", select "Add a device", scan or open the link, then compare codes and approve on the computer. See [pairing](../../README_EN.md#add-and-remove-devices).
|
|
62
|
+
|
|
63
|
+
## 4. Organization sign-in and embedding
|
|
64
|
+
|
|
65
|
+
Organizations can configure OIDC in `relay.env`, either alone or alongside keys:
|
|
66
|
+
|
|
67
|
+
```dotenv
|
|
68
|
+
RELAY_ACCESS_KEYS=
|
|
69
|
+
RELAY_OIDC_ISSUER=https://sso.example.edu
|
|
70
|
+
RELAY_OIDC_CLIENT_IDS=desktop-client-id
|
|
71
|
+
RELAY_FRAME_ANCESTORS=self https://portal.example.edu
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Replace these placeholders with your organization's configuration. The relay checks **RS256 ID Tokens**, not model keys or access tokens. The desktop also needs a compatible `dsh-oidc` and remote plugin configuration `organization: { relay, oidcProfileId }` to offer organization sign-in. Server settings do not create the desktop's organization configuration.
|
|
75
|
+
|
|
76
|
+
Set `RELAY_FRAME_ANCESTORS` only when iframe embedding is needed; embedding is blocked by default. Prefixes and ordinary iframes do not isolate same-origin privileges, so sharing an origin requires accepting the shared trust boundary. See the [deployment guide](../DEPLOYMENT_EN.md#5-organization-sign-in-and-iframe-optional) for OIDC, proxy headers and iframe details.
|
|
77
|
+
|
|
78
|
+
## 5. Configuration changes, upgrades and shutdown
|
|
79
|
+
|
|
80
|
+
After editing `relay.env`, recreate the container to apply the configuration:
|
|
81
|
+
|
|
82
|
+
```sh
|
|
83
|
+
docker compose up -d --force-recreate
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
For upgrades, set `REMOTE_ACCESS_VERSION` to the exact published version you intend to deploy; this example uses the current version. Run subsequent Compose commands in the same shell, or save the variable in a local `.env`, keeping the image tag and build argument consistent.
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
export REMOTE_ACCESS_VERSION=0.1.2
|
|
90
|
+
docker compose up -d --build
|
|
91
|
+
docker compose exec -T relay node -p "require('@eduwork/dsh-remote-access/package.json').version"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Images are built locally: `docker compose pull` does not replace rebuilding. To roll back, choose the previous version, restore compatible `relay.env` settings and rebuild. Retain your deployment configuration and previous version number. Do not share keys or tokens in logs.
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
docker compose down
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Stopping or upgrading the relay disconnects current connections; online computers and devices attempt to reconnect. Pairing state lives on the computer and browser, so the relay needs no data volume. Logs rotate automatically; stopping the relay does not delete desktop conversations or pairings.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: eduwork-remote
|
|
2
|
+
services:
|
|
3
|
+
relay:
|
|
4
|
+
# This image is built locally from the published npm package.
|
|
5
|
+
image: eduwork-remote-relay:${REMOTE_ACCESS_VERSION:-0.1.2}
|
|
6
|
+
build:
|
|
7
|
+
context: .
|
|
8
|
+
args:
|
|
9
|
+
REMOTE_ACCESS_VERSION: ${REMOTE_ACCESS_VERSION:-0.1.2}
|
|
10
|
+
restart: unless-stopped
|
|
11
|
+
init: true
|
|
12
|
+
env_file: relay.env
|
|
13
|
+
environment:
|
|
14
|
+
HOST: 0.0.0.0
|
|
15
|
+
PORT: "8787"
|
|
16
|
+
# A reverse proxy on this machine terminates HTTPS and forwards WebSockets.
|
|
17
|
+
ports:
|
|
18
|
+
- "127.0.0.1:8787:8787"
|
|
19
|
+
read_only: true
|
|
20
|
+
cap_drop: [ALL]
|
|
21
|
+
security_opt: ["no-new-privileges:true"]
|
|
22
|
+
logging:
|
|
23
|
+
driver: json-file
|
|
24
|
+
options:
|
|
25
|
+
max-size: "10m"
|
|
26
|
+
max-file: "3"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Probe the container listener, keeping the public URL's path prefix.
|
|
2
|
+
// Do not probe the public domain: TLS and proxy checks are separate.
|
|
3
|
+
try {
|
|
4
|
+
const base = new URL(process.env.RELAY_URL);
|
|
5
|
+
const probe = new URL('http://127.0.0.1');
|
|
6
|
+
probe.port = process.env.PORT || '8787';
|
|
7
|
+
probe.pathname = `${base.pathname.replace(/\/?$/, '/')}healthz`;
|
|
8
|
+
const response = await fetch(probe, {
|
|
9
|
+
redirect: 'error',
|
|
10
|
+
signal: AbortSignal.timeout(4000),
|
|
11
|
+
});
|
|
12
|
+
process.exit(response.ok && (await response.text()) === 'ok' ? 0 : 1);
|
|
13
|
+
} catch {
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Public HTTPS URL, including any prefix. Use the same URL on the desktop.
|
|
2
|
+
RELAY_URL=https://remote.example.edu/eduwork-remote/
|
|
3
|
+
|
|
4
|
+
# Replace with a random key; multiple keys are comma-separated.
|
|
5
|
+
# For OIDC-only deployments, leave this empty and configure BOTH OIDC values.
|
|
6
|
+
RELAY_ACCESS_KEYS=
|
|
7
|
+
|
|
8
|
+
# Optional organization sign-in; use your issuer and desktop application's ID.
|
|
9
|
+
# RELAY_OIDC_ISSUER=https://sso.example.edu
|
|
10
|
+
# RELAY_OIDC_CLIENT_IDS=desktop-client-id
|
|
11
|
+
|
|
12
|
+
# Optional: the trusted reverse proxy must OVERWRITE this request header.
|
|
13
|
+
# RELAY_CLIENT_IP_HEADER=x-real-ip
|
|
14
|
+
|
|
15
|
+
# Optional iframe parents: self, or complete origins separated by spaces.
|
|
16
|
+
# RELAY_FRAME_ANCESTORS=self https://portal.example.edu
|