inferyx-codegate 1.1.0__tar.gz
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.
- inferyx_codegate-1.1.0/.gitignore +9 -0
- inferyx_codegate-1.1.0/PKG-INFO +217 -0
- inferyx_codegate-1.1.0/README.md +191 -0
- inferyx_codegate-1.1.0/frontend/README.md +59 -0
- inferyx_codegate-1.1.0/pyproject.toml +40 -0
- inferyx_codegate-1.1.0/src/codegate/__init__.py +8 -0
- inferyx_codegate-1.1.0/src/codegate/__main__.py +3 -0
- inferyx_codegate-1.1.0/src/codegate/api/__init__.py +0 -0
- inferyx_codegate-1.1.0/src/codegate/api/admin.py +457 -0
- inferyx_codegate-1.1.0/src/codegate/api/deps.py +36 -0
- inferyx_codegate-1.1.0/src/codegate/api/devproxy.py +132 -0
- inferyx_codegate-1.1.0/src/codegate/api/public.py +371 -0
- inferyx_codegate-1.1.0/src/codegate/app.py +115 -0
- inferyx_codegate-1.1.0/src/codegate/auth/__init__.py +0 -0
- inferyx_codegate-1.1.0/src/codegate/auth/csrf.py +43 -0
- inferyx_codegate-1.1.0/src/codegate/auth/native.py +111 -0
- inferyx_codegate-1.1.0/src/codegate/auth/passwords.py +88 -0
- inferyx_codegate-1.1.0/src/codegate/auth/saml.py +222 -0
- inferyx_codegate-1.1.0/src/codegate/auth/sessions.py +121 -0
- inferyx_codegate-1.1.0/src/codegate/cli/__init__.py +0 -0
- inferyx_codegate-1.1.0/src/codegate/cli/auth_cmd.py +168 -0
- inferyx_codegate-1.1.0/src/codegate/cli/backup_cmd.py +114 -0
- inferyx_codegate-1.1.0/src/codegate/cli/common.py +103 -0
- inferyx_codegate-1.1.0/src/codegate/cli/doctor_cmd.py +136 -0
- inferyx_codegate-1.1.0/src/codegate/cli/main.py +526 -0
- inferyx_codegate-1.1.0/src/codegate/cli/nginx_setup.py +220 -0
- inferyx_codegate-1.1.0/src/codegate/cli/setup_cmd.py +401 -0
- inferyx_codegate-1.1.0/src/codegate/cli/ssh_setup.py +114 -0
- inferyx_codegate-1.1.0/src/codegate/cli/upgrade_cmd.py +209 -0
- inferyx_codegate-1.1.0/src/codegate/config.py +161 -0
- inferyx_codegate-1.1.0/src/codegate/db.py +297 -0
- inferyx_codegate-1.1.0/src/codegate/errors.py +122 -0
- inferyx_codegate-1.1.0/src/codegate/jobs.py +133 -0
- inferyx_codegate-1.1.0/src/codegate/pages.py +177 -0
- inferyx_codegate-1.1.0/src/codegate/resources/__init__.py +20 -0
- inferyx_codegate-1.1.0/src/codegate/resources/docker/Dockerfile +36 -0
- inferyx_codegate-1.1.0/src/codegate/resources/nginx/codegate.conf.tmpl +51 -0
- inferyx_codegate-1.1.0/src/codegate/resources/nginx/map.conf +5 -0
- inferyx_codegate-1.1.0/src/codegate/resources/nginx/site.conf.tmpl +9 -0
- inferyx_codegate-1.1.0/src/codegate/resources/nginx/user.conf.tmpl +19 -0
- inferyx_codegate-1.1.0/src/codegate/resources/systemd/codegate-backup.service.tmpl +7 -0
- inferyx_codegate-1.1.0/src/codegate/resources/systemd/codegate-backup.timer +10 -0
- inferyx_codegate-1.1.0/src/codegate/resources/systemd/codegate.service.tmpl +20 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/3rdpartylicenses.txt +614 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-0r_p7pcB.js +672 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-BoGqYCjO.js +1260 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-BqiJ460N.js +1269 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-BtoaIoDj.js +449 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-CB4E-q63.js +255 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-CMN75K3s.js +181 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-CW_CPa20.js +106 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-CcgsCK7w.js +393 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-Cjwyuum6.js +375 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-D6j6hnz3.js +1 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-D9RytJgO.js +1 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-DA6TldFU.js +35 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-DFGdyoNb.js +1 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-DXvCZ3pT.js +1 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-DstgVdtz.js +27 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-kPDFCwHP.js +102 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/chunk-yikJ2ObQ.js +1 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/favicon.ico +0 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/index.html +14 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/main-LWBML7JF.js +2347 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/media/material-icons-JLIDJUWE.woff +0 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/media/material-icons-LEZCGFVT.woff2 +0 -0
- inferyx_codegate-1.1.0/src/codegate/static/admin/styles-YWRWGLKG.css +1 -0
- inferyx_codegate-1.1.0/src/codegate/system/__init__.py +27 -0
- inferyx_codegate-1.1.0/src/codegate/system/base.py +165 -0
- inferyx_codegate-1.1.0/src/codegate/system/devdocker.py +90 -0
- inferyx_codegate-1.1.0/src/codegate/system/fake.py +199 -0
- inferyx_codegate-1.1.0/src/codegate/system/real.py +493 -0
- inferyx_codegate-1.1.0/src/codegate/system/shell.py +40 -0
- inferyx_codegate-1.1.0/src/codegate/users.py +262 -0
- inferyx_codegate-1.1.0/src/codegate/workspace.py +355 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: inferyx-codegate
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: Multi-user browser VS Code (code-server) on one server: password and AWS IAM Identity Center (SSO) login, per-user Docker workspaces and an admin portal.
|
|
5
|
+
Author: Inferyx
|
|
6
|
+
License: Proprietary
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: docker>=7.0
|
|
9
|
+
Requires-Dist: fastapi>=0.110
|
|
10
|
+
Requires-Dist: httpx>=0.27
|
|
11
|
+
Requires-Dist: packaging>=23.0
|
|
12
|
+
Requires-Dist: psutil>=5.9
|
|
13
|
+
Requires-Dist: pydantic-settings>=2.2
|
|
14
|
+
Requires-Dist: pydantic>=2.6
|
|
15
|
+
Requires-Dist: python-multipart>=0.0.9
|
|
16
|
+
Requires-Dist: rich>=13.7
|
|
17
|
+
Requires-Dist: sqlalchemy>=2.0
|
|
18
|
+
Requires-Dist: typer>=0.12
|
|
19
|
+
Requires-Dist: uvicorn[standard]>=0.29
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
22
|
+
Requires-Dist: python3-saml>=1.16; extra == 'dev'
|
|
23
|
+
Provides-Extra: saml
|
|
24
|
+
Requires-Dist: python3-saml>=1.16; extra == 'saml'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# CodeGate
|
|
28
|
+
|
|
29
|
+
Browser VS Code (code-server) for many users on one Ubuntu server. Each user gets their own
|
|
30
|
+
Docker workspace; admins manage everything from a web portal.
|
|
31
|
+
|
|
32
|
+
- **Login:** username/password, and optionally AWS IAM Identity Center (SSO).
|
|
33
|
+
- **One container per user**, with CPU/RAM/disk limits and its own home folder.
|
|
34
|
+
- **Admin portal** for users, approvals, resources, sessions, audit log and settings.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
https://code.example.com/codeapp/ → sign in
|
|
38
|
+
https://code.example.com/codeapp/editor/<username>/ → that user's VS Code
|
|
39
|
+
https://code.example.com/codeapp/admin/ → admin portal
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Requirements
|
|
43
|
+
|
|
44
|
+
- Ubuntu 24.04 server with root (sudo) access
|
|
45
|
+
- Python 3.10+ (`sudo apt install -y python3-pip python3-venv`)
|
|
46
|
+
- A DNS name pointing to the server, ports 80 and 443 open
|
|
47
|
+
- Optional: AWS IAM Identity Center, if you want SSO login
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# 1. install into its own virtual environment
|
|
53
|
+
sudo python3 -m venv /opt/codegate
|
|
54
|
+
sudo /opt/codegate/bin/pip install "inferyx-codegate[saml]"
|
|
55
|
+
sudo ln -sf /opt/codegate/bin/codegate /usr/local/bin/codegate
|
|
56
|
+
|
|
57
|
+
# 2. set everything up (asks for the domain and the default admin's email + password)
|
|
58
|
+
sudo codegate setup
|
|
59
|
+
|
|
60
|
+
# 3. check
|
|
61
|
+
sudo codegate doctor
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
If installing `[saml]` fails to build `xmlsec`, install `inferyx-codegate` without `[saml]`;
|
|
65
|
+
`codegate setup` then installs the system libraries and the SAML library for you.
|
|
66
|
+
|
|
67
|
+
Unattended install:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
sudo codegate setup -y --domain code.example.com --admin-email admin@example.com \
|
|
71
|
+
--admin-password-file /root/admin-pw.txt # omit to generate a password (shown once)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### What setup does
|
|
75
|
+
|
|
76
|
+
Setup is **safe to run again**: it checks each part and skips what's already in place.
|
|
77
|
+
|
|
78
|
+
| Part | What happens |
|
|
79
|
+
|---|---|
|
|
80
|
+
| Packages | Installs only what's missing: nginx, docker.io, quota, certbot, xmlsec libraries |
|
|
81
|
+
| Docker | Reuses an existing Docker install; builds the workspace image (code-server, Python, AWS CLI) |
|
|
82
|
+
| Default admin | Creates the first admin with password login. Must change a generated password at first login |
|
|
83
|
+
| nginx | Writes **only its own files** (`/etc/nginx/codegate/`, `/etc/nginx/conf.d/codegate-map.conf`). Never edits your existing nginx files (see below) |
|
|
84
|
+
| HTTPS | Runs certbot only for a site CodeGate created itself (`--skip-ssl` to skip) |
|
|
85
|
+
| Host SSH | Adds `/etc/ssh/sshd_config.d/10-codegate.conf` so workspace users can't SSH into the server |
|
|
86
|
+
| Service | systemd service `codegate` plus a daily backup timer |
|
|
87
|
+
| Existing code-server | Detected; you choose keep, stop or disable |
|
|
88
|
+
|
|
89
|
+
### nginx: one manual line
|
|
90
|
+
|
|
91
|
+
If your domain already has an nginx `server { }` block, add this line inside it (the 443
|
|
92
|
+
block), then reload nginx. Setup and `codegate doctor` show the exact file:
|
|
93
|
+
|
|
94
|
+
```nginx
|
|
95
|
+
include /etc/nginx/codegate/codegate.conf;
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
sudo nginx -t && sudo systemctl reload nginx
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
If the domain has no server block, setup creates its own site and you don't need this step.
|
|
103
|
+
|
|
104
|
+
## First sign-in
|
|
105
|
+
|
|
106
|
+
1. Open `https://<your-domain>/codeapp/` and sign in as the default admin.
|
|
107
|
+
2. Change the password when asked.
|
|
108
|
+
3. **Users → Add user**: enter the email, set a temporary password (or **Generate**), choose a
|
|
109
|
+
plan. The user's Linux account, home folder, container and route are created automatically.
|
|
110
|
+
4. Give the user their temporary password over a secure channel. They must change it at first
|
|
111
|
+
sign-in, then VS Code opens.
|
|
112
|
+
|
|
113
|
+
## AWS SSO login (optional)
|
|
114
|
+
|
|
115
|
+
1. AWS console → IAM Identity Center → **Applications** → **Add application** →
|
|
116
|
+
*I have an application I want to set up* → **SAML 2.0**.
|
|
117
|
+
2. In CodeGate: **Settings → Login**. Copy the **ACS URL** and **SAML audience** shown there into
|
|
118
|
+
the AWS application ("Manually type your metadata values").
|
|
119
|
+
3. AWS **Attribute mappings**:
|
|
120
|
+
|
|
121
|
+
| User attribute in the application | Maps to | Format |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| Subject | `${user:email}` | emailAddress |
|
|
124
|
+
| email | `${user:email}` | unspecified |
|
|
125
|
+
| name *(optional)* | `${user:name}` | unspecified |
|
|
126
|
+
|
|
127
|
+
4. Copy the **IAM Identity Center SAML metadata file** URL from AWS into **SAML metadata URL**,
|
|
128
|
+
click **Test metadata**, switch on **AWS SSO login**, and **Save**.
|
|
129
|
+
5. In AWS, **assign users or groups** to the application. New SSO users wait as *pending* until
|
|
130
|
+
an admin approves them, unless their email domain is on the auto-approve list.
|
|
131
|
+
|
|
132
|
+
Password login and SSO can each be switched off in **Settings → Login**; at least one stays on.
|
|
133
|
+
|
|
134
|
+
## Login security
|
|
135
|
+
|
|
136
|
+
- Passwords are stored only as salted scrypt hashes. Rules: at least 12 characters, 3 of
|
|
137
|
+
lowercase / uppercase / digit / symbol, not containing the username or email.
|
|
138
|
+
- After 5 failed attempts an account is locked for 15 minutes (adjustable); admins can unlock it
|
|
139
|
+
from the user page. Attempts are also rate-limited per IP address.
|
|
140
|
+
- Sessions use a random token in an `HttpOnly`, `Secure` cookie; only its hash is stored. A new
|
|
141
|
+
token is issued at every sign-in and password change. Session length and idle timeout are in
|
|
142
|
+
**Settings**.
|
|
143
|
+
- Changing or resetting a password ends the user's other sessions. Turning a login method off
|
|
144
|
+
ends the sessions that used it.
|
|
145
|
+
- Sign-in, sign-out and password forms are protected against cross-site requests.
|
|
146
|
+
|
|
147
|
+
### Locked out of the web portal?
|
|
148
|
+
|
|
149
|
+
On the server:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
sudo codegate user passwd <admin-username-or-email> # set a new password (--generate for random)
|
|
153
|
+
sudo codegate user unlock <user>
|
|
154
|
+
sudo codegate auth show
|
|
155
|
+
sudo codegate auth enable password
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Day-to-day commands
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
sudo codegate status | start | stop | restart | logs -f
|
|
162
|
+
sudo codegate doctor # checks everything, prints fix hints
|
|
163
|
+
sudo codegate user add dev@example.com --plan medium --password
|
|
164
|
+
sudo codegate user set <user> --plan large # CPU/RAM apply live
|
|
165
|
+
sudo codegate user delete <user> --remove-home # home is archived first
|
|
166
|
+
sudo codegate admin add second-admin@example.com
|
|
167
|
+
sudo codegate backup | restore <file>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Full list: `codegate --help`, and `codegate <command> --help`.
|
|
171
|
+
|
|
172
|
+
## Upgrade
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
sudo codegate upgrade --dry-run # show the plan
|
|
176
|
+
sudo codegate upgrade # latest version from PyPI
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Before upgrading, it backs up the database, config and nginx files, plus the installed package.
|
|
180
|
+
After installing, it runs migrations, refreshes nginx routes and restarts the service. If any
|
|
181
|
+
step fails, the previous version is restored automatically.
|
|
182
|
+
|
|
183
|
+
## Disk limits
|
|
184
|
+
|
|
185
|
+
Without Linux disk quotas, limits are monitored every 5 minutes and a workspace over its limit
|
|
186
|
+
is stopped. For hard limits, enable quotas on the `/home` filesystem (maintenance window):
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
sudo apt install -y quota linux-image-extra-virtual
|
|
190
|
+
# add usrquota to the /home (or /) line in /etc/fstab, then:
|
|
191
|
+
sudo mount -o remount /
|
|
192
|
+
sudo quotacheck -cum /
|
|
193
|
+
sudo quotaon -v /
|
|
194
|
+
sudo codegate doctor # "Disk quotas on /home" should show ✓
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Files
|
|
198
|
+
|
|
199
|
+
| Path | Contents |
|
|
200
|
+
|---|---|
|
|
201
|
+
| `/etc/codegate/codegate.env` | configuration (`codegate config show`) |
|
|
202
|
+
| `/var/lib/codegate/codegate.db` | database: users, sessions, audit log, settings |
|
|
203
|
+
| `/var/lib/codegate/backups/` | daily and pre-upgrade backups |
|
|
204
|
+
| `/var/log/codegate/codegate.log` | service log |
|
|
205
|
+
| `/etc/nginx/codegate/` | generated nginx config |
|
|
206
|
+
| `/home/<user>` | user files (mounted into their container) |
|
|
207
|
+
|
|
208
|
+
## Good to know
|
|
209
|
+
|
|
210
|
+
- Admins can't open other users' VS Code.
|
|
211
|
+
- Workspace users can't sign in to the server over SSH; they only get VS Code.
|
|
212
|
+
- **sudo inside a workspace** makes the user root in their container. Only give it to people you
|
|
213
|
+
would trust with the server. Mounting `/home` with `nosuid` adds protection
|
|
214
|
+
(`codegate doctor` checks it).
|
|
215
|
+
- The service runs as root (it manages Linux users, Docker and nginx) but listens only on
|
|
216
|
+
127.0.0.1; nginx is the only public entry point.
|
|
217
|
+
- Signing out of CodeGate doesn't sign the user out of the AWS access portal.
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# CodeGate
|
|
2
|
+
|
|
3
|
+
Browser VS Code (code-server) for many users on one Ubuntu server. Each user gets their own
|
|
4
|
+
Docker workspace; admins manage everything from a web portal.
|
|
5
|
+
|
|
6
|
+
- **Login:** username/password, and optionally AWS IAM Identity Center (SSO).
|
|
7
|
+
- **One container per user**, with CPU/RAM/disk limits and its own home folder.
|
|
8
|
+
- **Admin portal** for users, approvals, resources, sessions, audit log and settings.
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
https://code.example.com/codeapp/ → sign in
|
|
12
|
+
https://code.example.com/codeapp/editor/<username>/ → that user's VS Code
|
|
13
|
+
https://code.example.com/codeapp/admin/ → admin portal
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Requirements
|
|
17
|
+
|
|
18
|
+
- Ubuntu 24.04 server with root (sudo) access
|
|
19
|
+
- Python 3.10+ (`sudo apt install -y python3-pip python3-venv`)
|
|
20
|
+
- A DNS name pointing to the server, ports 80 and 443 open
|
|
21
|
+
- Optional: AWS IAM Identity Center, if you want SSO login
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# 1. install into its own virtual environment
|
|
27
|
+
sudo python3 -m venv /opt/codegate
|
|
28
|
+
sudo /opt/codegate/bin/pip install "inferyx-codegate[saml]"
|
|
29
|
+
sudo ln -sf /opt/codegate/bin/codegate /usr/local/bin/codegate
|
|
30
|
+
|
|
31
|
+
# 2. set everything up (asks for the domain and the default admin's email + password)
|
|
32
|
+
sudo codegate setup
|
|
33
|
+
|
|
34
|
+
# 3. check
|
|
35
|
+
sudo codegate doctor
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If installing `[saml]` fails to build `xmlsec`, install `inferyx-codegate` without `[saml]`;
|
|
39
|
+
`codegate setup` then installs the system libraries and the SAML library for you.
|
|
40
|
+
|
|
41
|
+
Unattended install:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
sudo codegate setup -y --domain code.example.com --admin-email admin@example.com \
|
|
45
|
+
--admin-password-file /root/admin-pw.txt # omit to generate a password (shown once)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### What setup does
|
|
49
|
+
|
|
50
|
+
Setup is **safe to run again**: it checks each part and skips what's already in place.
|
|
51
|
+
|
|
52
|
+
| Part | What happens |
|
|
53
|
+
|---|---|
|
|
54
|
+
| Packages | Installs only what's missing: nginx, docker.io, quota, certbot, xmlsec libraries |
|
|
55
|
+
| Docker | Reuses an existing Docker install; builds the workspace image (code-server, Python, AWS CLI) |
|
|
56
|
+
| Default admin | Creates the first admin with password login. Must change a generated password at first login |
|
|
57
|
+
| nginx | Writes **only its own files** (`/etc/nginx/codegate/`, `/etc/nginx/conf.d/codegate-map.conf`). Never edits your existing nginx files (see below) |
|
|
58
|
+
| HTTPS | Runs certbot only for a site CodeGate created itself (`--skip-ssl` to skip) |
|
|
59
|
+
| Host SSH | Adds `/etc/ssh/sshd_config.d/10-codegate.conf` so workspace users can't SSH into the server |
|
|
60
|
+
| Service | systemd service `codegate` plus a daily backup timer |
|
|
61
|
+
| Existing code-server | Detected; you choose keep, stop or disable |
|
|
62
|
+
|
|
63
|
+
### nginx: one manual line
|
|
64
|
+
|
|
65
|
+
If your domain already has an nginx `server { }` block, add this line inside it (the 443
|
|
66
|
+
block), then reload nginx. Setup and `codegate doctor` show the exact file:
|
|
67
|
+
|
|
68
|
+
```nginx
|
|
69
|
+
include /etc/nginx/codegate/codegate.conf;
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
sudo nginx -t && sudo systemctl reload nginx
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
If the domain has no server block, setup creates its own site and you don't need this step.
|
|
77
|
+
|
|
78
|
+
## First sign-in
|
|
79
|
+
|
|
80
|
+
1. Open `https://<your-domain>/codeapp/` and sign in as the default admin.
|
|
81
|
+
2. Change the password when asked.
|
|
82
|
+
3. **Users → Add user**: enter the email, set a temporary password (or **Generate**), choose a
|
|
83
|
+
plan. The user's Linux account, home folder, container and route are created automatically.
|
|
84
|
+
4. Give the user their temporary password over a secure channel. They must change it at first
|
|
85
|
+
sign-in, then VS Code opens.
|
|
86
|
+
|
|
87
|
+
## AWS SSO login (optional)
|
|
88
|
+
|
|
89
|
+
1. AWS console → IAM Identity Center → **Applications** → **Add application** →
|
|
90
|
+
*I have an application I want to set up* → **SAML 2.0**.
|
|
91
|
+
2. In CodeGate: **Settings → Login**. Copy the **ACS URL** and **SAML audience** shown there into
|
|
92
|
+
the AWS application ("Manually type your metadata values").
|
|
93
|
+
3. AWS **Attribute mappings**:
|
|
94
|
+
|
|
95
|
+
| User attribute in the application | Maps to | Format |
|
|
96
|
+
|---|---|---|
|
|
97
|
+
| Subject | `${user:email}` | emailAddress |
|
|
98
|
+
| email | `${user:email}` | unspecified |
|
|
99
|
+
| name *(optional)* | `${user:name}` | unspecified |
|
|
100
|
+
|
|
101
|
+
4. Copy the **IAM Identity Center SAML metadata file** URL from AWS into **SAML metadata URL**,
|
|
102
|
+
click **Test metadata**, switch on **AWS SSO login**, and **Save**.
|
|
103
|
+
5. In AWS, **assign users or groups** to the application. New SSO users wait as *pending* until
|
|
104
|
+
an admin approves them, unless their email domain is on the auto-approve list.
|
|
105
|
+
|
|
106
|
+
Password login and SSO can each be switched off in **Settings → Login**; at least one stays on.
|
|
107
|
+
|
|
108
|
+
## Login security
|
|
109
|
+
|
|
110
|
+
- Passwords are stored only as salted scrypt hashes. Rules: at least 12 characters, 3 of
|
|
111
|
+
lowercase / uppercase / digit / symbol, not containing the username or email.
|
|
112
|
+
- After 5 failed attempts an account is locked for 15 minutes (adjustable); admins can unlock it
|
|
113
|
+
from the user page. Attempts are also rate-limited per IP address.
|
|
114
|
+
- Sessions use a random token in an `HttpOnly`, `Secure` cookie; only its hash is stored. A new
|
|
115
|
+
token is issued at every sign-in and password change. Session length and idle timeout are in
|
|
116
|
+
**Settings**.
|
|
117
|
+
- Changing or resetting a password ends the user's other sessions. Turning a login method off
|
|
118
|
+
ends the sessions that used it.
|
|
119
|
+
- Sign-in, sign-out and password forms are protected against cross-site requests.
|
|
120
|
+
|
|
121
|
+
### Locked out of the web portal?
|
|
122
|
+
|
|
123
|
+
On the server:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
sudo codegate user passwd <admin-username-or-email> # set a new password (--generate for random)
|
|
127
|
+
sudo codegate user unlock <user>
|
|
128
|
+
sudo codegate auth show
|
|
129
|
+
sudo codegate auth enable password
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Day-to-day commands
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
sudo codegate status | start | stop | restart | logs -f
|
|
136
|
+
sudo codegate doctor # checks everything, prints fix hints
|
|
137
|
+
sudo codegate user add dev@example.com --plan medium --password
|
|
138
|
+
sudo codegate user set <user> --plan large # CPU/RAM apply live
|
|
139
|
+
sudo codegate user delete <user> --remove-home # home is archived first
|
|
140
|
+
sudo codegate admin add second-admin@example.com
|
|
141
|
+
sudo codegate backup | restore <file>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Full list: `codegate --help`, and `codegate <command> --help`.
|
|
145
|
+
|
|
146
|
+
## Upgrade
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
sudo codegate upgrade --dry-run # show the plan
|
|
150
|
+
sudo codegate upgrade # latest version from PyPI
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Before upgrading, it backs up the database, config and nginx files, plus the installed package.
|
|
154
|
+
After installing, it runs migrations, refreshes nginx routes and restarts the service. If any
|
|
155
|
+
step fails, the previous version is restored automatically.
|
|
156
|
+
|
|
157
|
+
## Disk limits
|
|
158
|
+
|
|
159
|
+
Without Linux disk quotas, limits are monitored every 5 minutes and a workspace over its limit
|
|
160
|
+
is stopped. For hard limits, enable quotas on the `/home` filesystem (maintenance window):
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
sudo apt install -y quota linux-image-extra-virtual
|
|
164
|
+
# add usrquota to the /home (or /) line in /etc/fstab, then:
|
|
165
|
+
sudo mount -o remount /
|
|
166
|
+
sudo quotacheck -cum /
|
|
167
|
+
sudo quotaon -v /
|
|
168
|
+
sudo codegate doctor # "Disk quotas on /home" should show ✓
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Files
|
|
172
|
+
|
|
173
|
+
| Path | Contents |
|
|
174
|
+
|---|---|
|
|
175
|
+
| `/etc/codegate/codegate.env` | configuration (`codegate config show`) |
|
|
176
|
+
| `/var/lib/codegate/codegate.db` | database: users, sessions, audit log, settings |
|
|
177
|
+
| `/var/lib/codegate/backups/` | daily and pre-upgrade backups |
|
|
178
|
+
| `/var/log/codegate/codegate.log` | service log |
|
|
179
|
+
| `/etc/nginx/codegate/` | generated nginx config |
|
|
180
|
+
| `/home/<user>` | user files (mounted into their container) |
|
|
181
|
+
|
|
182
|
+
## Good to know
|
|
183
|
+
|
|
184
|
+
- Admins can't open other users' VS Code.
|
|
185
|
+
- Workspace users can't sign in to the server over SSH; they only get VS Code.
|
|
186
|
+
- **sudo inside a workspace** makes the user root in their container. Only give it to people you
|
|
187
|
+
would trust with the server. Mounting `/home` with `nosuid` adds protection
|
|
188
|
+
(`codegate doctor` checks it).
|
|
189
|
+
- The service runs as root (it manages Linux users, Docker and nginx) but listens only on
|
|
190
|
+
127.0.0.1; nginx is the only public entry point.
|
|
191
|
+
- Signing out of CodeGate doesn't sign the user out of the AWS access portal.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Frontend
|
|
2
|
+
|
|
3
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 22.3.0.
|
|
4
|
+
|
|
5
|
+
## Development server
|
|
6
|
+
|
|
7
|
+
To start a local development server, run:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
ng serve
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
|
|
14
|
+
|
|
15
|
+
## Code scaffolding
|
|
16
|
+
|
|
17
|
+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
ng generate component component-name
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
ng generate --help
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Building
|
|
30
|
+
|
|
31
|
+
To build the project run:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
ng build
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
|
|
38
|
+
|
|
39
|
+
## Running unit tests
|
|
40
|
+
|
|
41
|
+
To execute unit tests with the [Vitest](https://vitest.dev/) test runner, use the following command:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
ng test
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Running end-to-end tests
|
|
48
|
+
|
|
49
|
+
For end-to-end (e2e) testing, run:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
ng e2e
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
|
|
56
|
+
|
|
57
|
+
## Additional Resources
|
|
58
|
+
|
|
59
|
+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.25"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "inferyx-codegate"
|
|
7
|
+
version = "1.1.0"
|
|
8
|
+
description = "Multi-user browser VS Code (code-server) on one server: password and AWS IAM Identity Center (SSO) login, per-user Docker workspaces and an admin portal."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "Proprietary" }
|
|
12
|
+
authors = [{ name = "Inferyx" }]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"fastapi>=0.110",
|
|
15
|
+
"uvicorn[standard]>=0.29",
|
|
16
|
+
"sqlalchemy>=2.0",
|
|
17
|
+
"pydantic>=2.6",
|
|
18
|
+
"pydantic-settings>=2.2",
|
|
19
|
+
"typer>=0.12",
|
|
20
|
+
"rich>=13.7",
|
|
21
|
+
"docker>=7.0",
|
|
22
|
+
"httpx>=0.27",
|
|
23
|
+
"psutil>=5.9",
|
|
24
|
+
"packaging>=23.0",
|
|
25
|
+
"python-multipart>=0.0.9",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.optional-dependencies]
|
|
29
|
+
# SAML needs system libs: apt install libxml2-dev libxmlsec1-dev libxmlsec1-openssl pkg-config
|
|
30
|
+
saml = ["python3-saml>=1.16"]
|
|
31
|
+
dev = ["pytest>=8", "python3-saml>=1.16"]
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
codegate = "codegate.cli.main:app"
|
|
35
|
+
|
|
36
|
+
[tool.hatch.build.targets.wheel]
|
|
37
|
+
packages = ["src/codegate"]
|
|
38
|
+
|
|
39
|
+
[tool.hatch.build.targets.sdist]
|
|
40
|
+
include = ["src/codegate", "README.md", "pyproject.toml"]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""CodeGate - browser VS Code with AWS SSO login and per-user Docker workspaces."""
|
|
2
|
+
|
|
3
|
+
__version__ = "1.1.0"
|
|
4
|
+
|
|
5
|
+
# pip distribution name (PyPI). The import package and the CLI command stay "codegate".
|
|
6
|
+
PACKAGE_NAME = "inferyx-codegate"
|
|
7
|
+
# earlier builds were installed from .whl files under this name
|
|
8
|
+
LEGACY_PACKAGE_NAMES = ("codegate",)
|
|
File without changes
|