inferyx-codegate 1.1.0__py3-none-any.whl
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.
- codegate/__init__.py +8 -0
- codegate/__main__.py +3 -0
- codegate/api/__init__.py +0 -0
- codegate/api/admin.py +457 -0
- codegate/api/deps.py +36 -0
- codegate/api/devproxy.py +132 -0
- codegate/api/public.py +371 -0
- codegate/app.py +115 -0
- codegate/auth/__init__.py +0 -0
- codegate/auth/csrf.py +43 -0
- codegate/auth/native.py +111 -0
- codegate/auth/passwords.py +88 -0
- codegate/auth/saml.py +222 -0
- codegate/auth/sessions.py +121 -0
- codegate/cli/__init__.py +0 -0
- codegate/cli/auth_cmd.py +168 -0
- codegate/cli/backup_cmd.py +114 -0
- codegate/cli/common.py +103 -0
- codegate/cli/doctor_cmd.py +136 -0
- codegate/cli/main.py +526 -0
- codegate/cli/nginx_setup.py +220 -0
- codegate/cli/setup_cmd.py +401 -0
- codegate/cli/ssh_setup.py +114 -0
- codegate/cli/upgrade_cmd.py +209 -0
- codegate/config.py +161 -0
- codegate/db.py +297 -0
- codegate/errors.py +122 -0
- codegate/jobs.py +133 -0
- codegate/pages.py +177 -0
- codegate/resources/__init__.py +20 -0
- codegate/resources/docker/Dockerfile +36 -0
- codegate/resources/nginx/codegate.conf.tmpl +51 -0
- codegate/resources/nginx/map.conf +5 -0
- codegate/resources/nginx/site.conf.tmpl +9 -0
- codegate/resources/nginx/user.conf.tmpl +19 -0
- codegate/resources/systemd/codegate-backup.service.tmpl +7 -0
- codegate/resources/systemd/codegate-backup.timer +10 -0
- codegate/resources/systemd/codegate.service.tmpl +20 -0
- codegate/static/admin/3rdpartylicenses.txt +614 -0
- codegate/static/admin/chunk-0r_p7pcB.js +672 -0
- codegate/static/admin/chunk-BoGqYCjO.js +1260 -0
- codegate/static/admin/chunk-BqiJ460N.js +1269 -0
- codegate/static/admin/chunk-BtoaIoDj.js +449 -0
- codegate/static/admin/chunk-CB4E-q63.js +255 -0
- codegate/static/admin/chunk-CMN75K3s.js +181 -0
- codegate/static/admin/chunk-CW_CPa20.js +106 -0
- codegate/static/admin/chunk-CcgsCK7w.js +393 -0
- codegate/static/admin/chunk-Cjwyuum6.js +375 -0
- codegate/static/admin/chunk-D6j6hnz3.js +1 -0
- codegate/static/admin/chunk-D9RytJgO.js +1 -0
- codegate/static/admin/chunk-DA6TldFU.js +35 -0
- codegate/static/admin/chunk-DFGdyoNb.js +1 -0
- codegate/static/admin/chunk-DXvCZ3pT.js +1 -0
- codegate/static/admin/chunk-DstgVdtz.js +27 -0
- codegate/static/admin/chunk-kPDFCwHP.js +102 -0
- codegate/static/admin/chunk-yikJ2ObQ.js +1 -0
- codegate/static/admin/favicon.ico +0 -0
- codegate/static/admin/index.html +14 -0
- codegate/static/admin/main-LWBML7JF.js +2347 -0
- codegate/static/admin/media/material-icons-JLIDJUWE.woff +0 -0
- codegate/static/admin/media/material-icons-LEZCGFVT.woff2 +0 -0
- codegate/static/admin/styles-YWRWGLKG.css +1 -0
- codegate/system/__init__.py +27 -0
- codegate/system/base.py +165 -0
- codegate/system/devdocker.py +90 -0
- codegate/system/fake.py +199 -0
- codegate/system/real.py +493 -0
- codegate/system/shell.py +40 -0
- codegate/users.py +262 -0
- codegate/workspace.py +355 -0
- inferyx_codegate-1.1.0.dist-info/METADATA +217 -0
- inferyx_codegate-1.1.0.dist-info/RECORD +74 -0
- inferyx_codegate-1.1.0.dist-info/WHEEL +4 -0
- inferyx_codegate-1.1.0.dist-info/entry_points.txt +2 -0
codegate/pages.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"""Small server-rendered pages (login, pending, forbidden, starting, logged out)."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import html
|
|
5
|
+
import secrets
|
|
6
|
+
|
|
7
|
+
from fastapi.responses import HTMLResponse
|
|
8
|
+
|
|
9
|
+
from .config import get_settings
|
|
10
|
+
|
|
11
|
+
_CSS = """
|
|
12
|
+
*{box-sizing:border-box}body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
|
|
13
|
+
background:#0f172a;color:#e2e8f0;display:flex;min-height:100vh;align-items:center;justify-content:center}
|
|
14
|
+
.card{background:#1e293b;border:1px solid #334155;border-radius:14px;padding:36px 40px;max-width:440px;
|
|
15
|
+
width:92%;text-align:center;box-shadow:0 10px 40px rgba(0,0,0,.35)}
|
|
16
|
+
h1{font-size:20px;margin:14px 0 8px}p{color:#94a3b8;line-height:1.5;margin:8px 0}
|
|
17
|
+
.logo{font-weight:700;letter-spacing:.5px;color:#38bdf8}
|
|
18
|
+
a.btn,button{display:inline-block;margin-top:18px;background:#0ea5e9;color:#fff;border:0;border-radius:8px;
|
|
19
|
+
padding:10px 20px;font-size:15px;text-decoration:none;cursor:pointer}
|
|
20
|
+
a.btn.secondary{background:transparent;border:1px solid #475569;color:#cbd5e1}
|
|
21
|
+
label{display:block;text-align:left;font-size:13px;color:#94a3b8;margin-top:12px}
|
|
22
|
+
label input{margin-top:4px}
|
|
23
|
+
.or{display:flex;align-items:center;gap:10px;color:#64748b;font-size:12px;margin:18px 0 0}
|
|
24
|
+
.or:before,.or:after{content:"";flex:1;height:1px;background:#334155}
|
|
25
|
+
button.full,a.full{width:100%;text-align:center}
|
|
26
|
+
.ok{color:#86efac}
|
|
27
|
+
input{width:100%;padding:10px;border-radius:8px;border:1px solid #475569;background:#0f172a;color:#e2e8f0;
|
|
28
|
+
margin-top:12px;font-size:15px}
|
|
29
|
+
.spin{width:38px;height:38px;border:4px solid #334155;border-top-color:#38bdf8;border-radius:50%;
|
|
30
|
+
margin:8px auto;animation:s 1s linear infinite}@keyframes s{to{transform:rotate(360deg)}}
|
|
31
|
+
.err{color:#fca5a5}.small{font-size:12px;color:#64748b;margin-top:18px}
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class Page(str):
|
|
36
|
+
"""HTML plus the CSP nonce its inline script uses (see respond())."""
|
|
37
|
+
nonce: str = ""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def page(title: str, body: str, *, script: str = "") -> Page:
|
|
41
|
+
nonce = secrets.token_urlsafe(16)
|
|
42
|
+
out = Page(f"""<!doctype html><html lang="en"><head><meta charset="utf-8">
|
|
43
|
+
<meta name="viewport" content="width=device-width,initial-scale=1"><title>{html.escape(title)} · CodeGate</title>
|
|
44
|
+
<style>{_CSS}</style></head><body><div class="card"><div class="logo">⟨/⟩ CodeGate</div>{body}</div>
|
|
45
|
+
{f'<script nonce="{nonce}">{script}</script>' if script else ''}</body></html>""")
|
|
46
|
+
out.nonce = nonce
|
|
47
|
+
return out
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def respond(content: Page | str, status_code: int = 200) -> HTMLResponse:
|
|
51
|
+
"""HTML response with strict security headers; never cached."""
|
|
52
|
+
nonce = getattr(content, "nonce", "")
|
|
53
|
+
script_src = f"'nonce-{nonce}'" if nonce else "'none'"
|
|
54
|
+
csp = ("default-src 'none'; style-src 'unsafe-inline'; img-src 'self' data:; "
|
|
55
|
+
f"script-src {script_src}; connect-src 'self'; form-action 'self'; "
|
|
56
|
+
"frame-ancestors 'none'; base-uri 'none'")
|
|
57
|
+
return HTMLResponse(str(content), status_code=status_code, headers={
|
|
58
|
+
"Content-Security-Policy": csp, "Cache-Control": "no-store", "Pragma": "no-cache"})
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _b() -> str:
|
|
62
|
+
return get_settings().base_path
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def pending_page(email: str) -> str:
|
|
66
|
+
return page("Waiting for approval", f"""<h1>Waiting for admin approval</h1>
|
|
67
|
+
<p>You are signed in as <b>{html.escape(email)}</b>.</p>
|
|
68
|
+
<p>An admin needs to approve your access. Try again after you get confirmation.</p>
|
|
69
|
+
<a class="btn" href="{_b()}/">Check again</a> <a class="btn secondary" href="{_b()}/logout">Logout</a>""")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def forbidden_page(email: str | None, reason: str = "") -> str:
|
|
73
|
+
who = f"<p>Signed in as <b>{html.escape(email)}</b>.</p>" if email else ""
|
|
74
|
+
return page("Access denied", f"""<h1>Access denied</h1>{who}
|
|
75
|
+
<p>{html.escape(reason or 'Your access is disabled or has expired. Contact your admin.')}</p>
|
|
76
|
+
<a class="btn" href="{_b()}/">Home</a> <a class="btn secondary" href="{_b()}/logout">Logout</a>""")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def logged_out_page() -> str:
|
|
80
|
+
return page("Logged out", f"""<h1>You are logged out</h1>
|
|
81
|
+
<p>Your CodeGate session has ended.</p><a class="btn" href="{_b()}/login">Login again</a>
|
|
82
|
+
<p class="small">Note: you may still be signed in to the AWS access portal.</p>""")
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def error_page(title: str, message: str, error_id: str = "") -> str:
|
|
86
|
+
extra = f'<p class="small">Error id: {html.escape(error_id)}</p>' if error_id else ""
|
|
87
|
+
return page(title, f"""<h1 class="err">{html.escape(title)}</h1><p>{html.escape(message)}</p>
|
|
88
|
+
{extra}<a class="btn" href="{_b()}/login">Try again</a>""")
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def starting_page(username: str) -> str:
|
|
92
|
+
b = _b()
|
|
93
|
+
script = f"""
|
|
94
|
+
const base={b!r}, user={username!r};
|
|
95
|
+
let tries=0;
|
|
96
|
+
async function poll(){{
|
|
97
|
+
tries++;
|
|
98
|
+
try{{
|
|
99
|
+
const r=await fetch(base+'/api/me/workspace/status',{{credentials:'same-origin'}});
|
|
100
|
+
if(r.status===401){{location.href=base+'/login?next='+encodeURIComponent(location.pathname);return;}}
|
|
101
|
+
const d=await r.json();
|
|
102
|
+
document.getElementById('st').textContent=d.message||d.status;
|
|
103
|
+
if(d.ready){{location.reload();return;}}
|
|
104
|
+
if(d.status==='error'){{document.getElementById('st').className='err';return;}}
|
|
105
|
+
if(d.status==='dev'){{return;}}
|
|
106
|
+
}}catch(e){{}}
|
|
107
|
+
if(tries<90) setTimeout(poll,2000); else document.getElementById('st').textContent='Taking too long. Refresh or contact admin.';
|
|
108
|
+
}}
|
|
109
|
+
fetch(base+'/api/me/workspace/start',{{method:'POST',credentials:'same-origin',headers:{{'X-CodeGate':'1'}}}})
|
|
110
|
+
.finally(()=>setTimeout(poll,1500));
|
|
111
|
+
"""
|
|
112
|
+
return page("Starting workspace", f"""<div class="spin"></div><h1>Starting your workspace…</h1>
|
|
113
|
+
<p id="st">Please wait a few seconds.</p>
|
|
114
|
+
<p class="small">VS Code opens automatically when it's ready.</p>""", script=script)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _csrf_field(token: str) -> str:
|
|
118
|
+
return f'<input type="hidden" name="csrf" value="{html.escape(token)}">'
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def login_page(*, csrf: str, next_url: str = "", error: str = "", info: str = "",
|
|
122
|
+
password_enabled: bool = True, sso_enabled: bool = False,
|
|
123
|
+
username: str = "") -> Page:
|
|
124
|
+
b = _b()
|
|
125
|
+
err = f'<p class="err" role="alert">{html.escape(error)}</p>' if error else ""
|
|
126
|
+
inf = f'<p class="ok">{html.escape(info)}</p>' if info else ""
|
|
127
|
+
nxt = f'<input type="hidden" name="next" value="{html.escape(next_url)}">' if next_url else ""
|
|
128
|
+
parts = [f"<h1>Sign in</h1>{err}{inf}"]
|
|
129
|
+
if password_enabled:
|
|
130
|
+
parts.append(f"""<form method="post" action="{b}/login" autocomplete="on">{_csrf_field(csrf)}{nxt}
|
|
131
|
+
<label>Username or email<input name="username" autocomplete="username" required maxlength="320"
|
|
132
|
+
value="{html.escape(username)}" {'autofocus' if not username else ''}></label>
|
|
133
|
+
<label>Password<input name="password" type="password" autocomplete="current-password" required
|
|
134
|
+
maxlength="256" {'autofocus' if username else ''}></label>
|
|
135
|
+
<button type="submit" class="full">Sign in</button></form>""")
|
|
136
|
+
if sso_enabled:
|
|
137
|
+
q = f"?next={html.escape(next_url)}" if next_url else ""
|
|
138
|
+
if password_enabled:
|
|
139
|
+
parts.append('<div class="or">or</div>')
|
|
140
|
+
parts.append(f'<a class="btn full{" secondary" if password_enabled else ""}" '
|
|
141
|
+
f'href="{b}/saml/login{q}">Sign in with AWS SSO</a>')
|
|
142
|
+
if not password_enabled and not sso_enabled:
|
|
143
|
+
parts.append('<p class="err">No login method is enabled. An administrator can re-enable '
|
|
144
|
+
'password login on the server: <code>sudo codegate auth enable password</code></p>')
|
|
145
|
+
return page("Sign in", "".join(parts))
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def logout_confirm_page(csrf: str) -> Page:
|
|
149
|
+
return page("Log out", f"""<h1>Log out?</h1>
|
|
150
|
+
<form method="post" action="{_b()}/logout">{_csrf_field(csrf)}
|
|
151
|
+
<button type="submit">Log out</button> <a class="btn secondary" href="{_b()}/">Cancel</a></form>""")
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def change_password_page(*, csrf: str, email: str, forced: bool, error: str = "",
|
|
155
|
+
min_length: int = 12, next_url: str = "") -> Page:
|
|
156
|
+
b = _b()
|
|
157
|
+
err = f'<p class="err" role="alert">{html.escape(error)}</p>' if error else ""
|
|
158
|
+
why = ("<p>Please choose a new password before you continue.</p>" if forced
|
|
159
|
+
else "<p>Change the password you use to sign in.</p>")
|
|
160
|
+
nxt = f'<input type="hidden" name="next" value="{html.escape(next_url)}">' if next_url else ""
|
|
161
|
+
cancel = "" if forced else f' <a class="btn secondary" href="{b}/">Cancel</a>'
|
|
162
|
+
return page("Change password", f"""<h1>Change password</h1>
|
|
163
|
+
<p>Signed in as <b>{html.escape(email)}</b>.</p>{why}{err}
|
|
164
|
+
<form method="post" action="{b}/account/password">{_csrf_field(csrf)}{nxt}
|
|
165
|
+
<input type="hidden" name="username" value="{html.escape(email)}" autocomplete="username">
|
|
166
|
+
<label>Current password<input name="current" type="password" autocomplete="current-password" required maxlength="256" autofocus></label>
|
|
167
|
+
<label>New password<input name="new" type="password" autocomplete="new-password" required minlength="{min_length}" maxlength="256"></label>
|
|
168
|
+
<label>Repeat new password<input name="confirm" type="password" autocomplete="new-password" required minlength="{min_length}" maxlength="256"></label>
|
|
169
|
+
<p class="small">At least {min_length} characters, with 3 of: lowercase, uppercase, digit, symbol.</p>
|
|
170
|
+
<button type="submit">Change password</button>{cancel}</form>
|
|
171
|
+
<p class="small"><a href="{b}/logout" style="color:#94a3b8">Log out</a></p>""")
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def no_password_page(email: str) -> Page:
|
|
175
|
+
return page("Password", f"""<h1>No password set</h1>
|
|
176
|
+
<p><b>{html.escape(email)}</b> signs in with AWS SSO. Ask an admin to set a password if you need one.</p>
|
|
177
|
+
<a class="btn" href="{_b()}/">Home</a>""")
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""Packaged resource files (nginx templates, Dockerfile, systemd unit, pages)."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from importlib import resources
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def read(rel: str) -> str:
|
|
8
|
+
return resources.files(__name__).joinpath(rel).read_text()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def path(rel: str):
|
|
12
|
+
return resources.files(__name__).joinpath(rel)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def render(rel: str, **values: object) -> str:
|
|
16
|
+
"""Templates use @@KEY@@ placeholders (safe with nginx $vars and {braces})."""
|
|
17
|
+
text = read(rel)
|
|
18
|
+
for key, val in values.items():
|
|
19
|
+
text = text.replace(f"@@{key.upper()}@@", str(val))
|
|
20
|
+
return text
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# CodeGate workspace image: code-server + Python dev tools + AWS CLI.
|
|
2
|
+
# Built on the server by: sudo codegate image build
|
|
3
|
+
FROM ubuntu:24.04
|
|
4
|
+
|
|
5
|
+
ARG DEBIAN_FRONTEND=noninteractive
|
|
6
|
+
ARG CODE_SERVER_VERSION=
|
|
7
|
+
|
|
8
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
9
|
+
ca-certificates curl wget git openssh-client sudo less nano vim unzip zip jq \
|
|
10
|
+
bash-completion locales tzdata procps htop build-essential \
|
|
11
|
+
python3 python3-pip python3-venv python3-dev pipx \
|
|
12
|
+
&& locale-gen en_US.UTF-8 \
|
|
13
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
14
|
+
|
|
15
|
+
# code-server (standalone install into /usr/local)
|
|
16
|
+
RUN if [ -n "$CODE_SERVER_VERSION" ]; then V="--version $CODE_SERVER_VERSION"; else V=""; fi \
|
|
17
|
+
&& curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/usr/local $V \
|
|
18
|
+
&& code-server --version
|
|
19
|
+
|
|
20
|
+
# AWS CLI v2
|
|
21
|
+
RUN ARCH="$(uname -m)" \
|
|
22
|
+
&& curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-${ARCH}.zip" -o /tmp/awscli.zip \
|
|
23
|
+
&& unzip -q /tmp/awscli.zip -d /tmp && /tmp/aws/install && rm -rf /tmp/aws /tmp/awscli.zip \
|
|
24
|
+
&& aws --version
|
|
25
|
+
|
|
26
|
+
# sudo only works when the admin enables it (a sudoers file is mounted per user)
|
|
27
|
+
RUN rm -f /etc/sudoers.d/* && echo 'Defaults !requiretty' > /etc/sudoers.d/00-defaults \
|
|
28
|
+
&& chmod 440 /etc/sudoers.d/00-defaults
|
|
29
|
+
|
|
30
|
+
ENV LANG=en_US.UTF-8 \
|
|
31
|
+
LC_ALL=en_US.UTF-8 \
|
|
32
|
+
PIP_DISABLE_PIP_VERSION_CHECK=1
|
|
33
|
+
|
|
34
|
+
EXPOSE 8080
|
|
35
|
+
LABEL codegate.managed="1"
|
|
36
|
+
CMD ["code-server", "--bind-addr", "0.0.0.0:8080", "--auth", "none"]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# ---------------------------------------------------------------
|
|
2
|
+
# Managed by CodeGate - DO NOT EDIT (regenerated by: codegate nginx sync)
|
|
3
|
+
# Included inside the server { } block of @@DOMAIN@@
|
|
4
|
+
# ---------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
location = @@BASE@@ {
|
|
7
|
+
return 302 @@BASE@@/;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
# Backend: login, SSO, admin portal, API
|
|
11
|
+
location @@BASE@@/ {
|
|
12
|
+
proxy_pass http://@@BACKEND@@;
|
|
13
|
+
proxy_http_version 1.1;
|
|
14
|
+
proxy_set_header Host $host;
|
|
15
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
16
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
17
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
18
|
+
client_max_body_size 20m;
|
|
19
|
+
proxy_read_timeout 120s;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# Session check used by every editor request (nginx auth_request)
|
|
23
|
+
location @@BASE@@/_auth/ {
|
|
24
|
+
internal;
|
|
25
|
+
proxy_pass http://@@BACKEND@@;
|
|
26
|
+
proxy_pass_request_body off;
|
|
27
|
+
proxy_set_header Content-Length "";
|
|
28
|
+
proxy_set_header Host $host;
|
|
29
|
+
proxy_set_header X-Original-URI $request_uri;
|
|
30
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
31
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
location @codegate_login {
|
|
35
|
+
return 302 @@BASE@@/login?next=$uri;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
location @codegate_forbidden {
|
|
39
|
+
return 302 @@BASE@@/forbidden;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Workspace not reachable (stopped / starting) -> backend shows "Starting..." page
|
|
43
|
+
location @codegate_starting {
|
|
44
|
+
proxy_pass http://@@BACKEND@@;
|
|
45
|
+
proxy_set_header Host $host;
|
|
46
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
47
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# One file per user: /codeapp/editor/<username>/ -> that user's container
|
|
51
|
+
include @@USERS_DIR@@/*.conf;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Managed by CodeGate - DO NOT EDIT. user=@@USER@@ port=@@PORT@@
|
|
2
|
+
location @@BASE@@/editor/@@USER@@/ {
|
|
3
|
+
auth_request @@BASE@@/_auth/@@USER@@;
|
|
4
|
+
error_page 401 = @codegate_login;
|
|
5
|
+
error_page 403 = @codegate_forbidden;
|
|
6
|
+
error_page 502 503 504 = @codegate_starting;
|
|
7
|
+
|
|
8
|
+
proxy_pass http://127.0.0.1:@@PORT@@/;
|
|
9
|
+
proxy_http_version 1.1;
|
|
10
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
11
|
+
proxy_set_header Connection $codegate_connection_upgrade;
|
|
12
|
+
proxy_set_header Host $host;
|
|
13
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
14
|
+
proxy_set_header Accept-Encoding gzip;
|
|
15
|
+
proxy_read_timeout 1d;
|
|
16
|
+
proxy_send_timeout 1d;
|
|
17
|
+
proxy_buffering off;
|
|
18
|
+
client_max_body_size 1g;
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=CodeGate - browser VS Code with AWS SSO
|
|
3
|
+
After=network-online.target docker.service nginx.service
|
|
4
|
+
Wants=network-online.target docker.service
|
|
5
|
+
|
|
6
|
+
[Service]
|
|
7
|
+
Type=simple
|
|
8
|
+
Environment=CODEGATE_ENV_FILE=@@ENV_FILE@@
|
|
9
|
+
ExecStart=@@EXEC@@ run
|
|
10
|
+
Restart=on-failure
|
|
11
|
+
RestartSec=5
|
|
12
|
+
# needs root: useradd, setquota, docker, nginx reload, iptables (listens on 127.0.0.1 only)
|
|
13
|
+
User=root
|
|
14
|
+
NoNewPrivileges=false
|
|
15
|
+
LimitNOFILE=65536
|
|
16
|
+
StandardOutput=append:@@LOG_DIR@@/codegate.log
|
|
17
|
+
StandardError=append:@@LOG_DIR@@/codegate.log
|
|
18
|
+
|
|
19
|
+
[Install]
|
|
20
|
+
WantedBy=multi-user.target
|