-
Notifications
You must be signed in to change notification settings - Fork 1
External API gateway (services/gateway) + resolve-discord endpoint (#59) #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
3d6996a
41ced60
5016b95
6189bb7
cb37093
429b864
52e86bc
e56b6e4
656e30a
18c5818
099a4d9
1998b15
61b8fe5
33e00a4
537abfa
84e651f
65a85e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| .venv | ||
| __pycache__ | ||
| *.pyc | ||
| .env | ||
| .pytest_cache |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| DATABASE_URL=postgresql+psycopg://gateway:dev_password@localhost:5435/gateway | ||
|
|
||
| # No API_KEY. Unlike the internal services, the gateway has no env-bootstrap | ||
| # admin key — inbound callers must present a scoped key issued by `gateway-keys` | ||
| # and stored in the api_keys table. See src/api/auth.py. | ||
|
|
||
| # Outbound: the gateway's own team-tracking key, scoped identifiers:read. | ||
| DIRECTORY_BASE_URL=http://localhost:8000 | ||
| DIRECTORY_API_KEY=dev-api-key-change-me | ||
|
|
||
| GATEWAY_ENV=local | ||
|
|
||
| # Set to true wherever a proxy terminates TLS in front of the gateway (Railway | ||
| # does). Off by default so a directly-exposed deploy can't be handed a spoofed | ||
| # X-Forwarded-For and slip the per-IP rate limit. | ||
| TRUST_PROXY_HEADERS=false |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| FROM python:3.11-slim | ||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv | ||||||||||||||||||||||||||||||||||||||||||||||||||
| WORKDIR /app | ||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY pyproject.toml uv.lock ./ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY packages/ ./packages/ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| COPY services/gateway/ ./services/gateway/ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| RUN uv sync --frozen --no-dev --package gateway | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ENV PATH="/app/.venv/bin:$PATH" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| WORKDIR /app/services/gateway | ||||||||||||||||||||||||||||||||||||||||||||||||||
| EXPOSE 8000 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| CMD ["uvicorn", "src.api.app:app", "--host", "0.0.0.0", "--port", "8000"] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win Run the gateway as a non-root user. The container currently starts Uvicorn as root. For a public-facing gateway, that’s unnecessary risk. 🔧 Suggested Dockerfile hardening FROM python:3.11-slim
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
WORKDIR /app
COPY pyproject.toml uv.lock ./
COPY packages/ ./packages/
COPY services/gateway/ ./services/gateway/
RUN uv sync --frozen --no-dev --package gateway
ENV PATH="/app/.venv/bin:$PATH"
+RUN addgroup --system gateway && adduser --system --ingroup gateway gateway
+USER gateway
WORKDIR /app/services/gateway
EXPOSE 8000
CMD ["uvicorn", "src.api.app:app", "--host", "0.0.0.0", "--port", "8000"]📝 Committable suggestion
Suggested change
🧰 Tools🪛 Trivy (0.69.3)[error] 1-1: Image user should not be 'root' Specify at least 1 USER command in Dockerfile with non-root user as argument Rule: DS-0002 (IaC/Dockerfile) 🤖 Prompt for AI AgentsSource: Linters/SAST tools |
||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
Tighten checkout credentials and job permissions.
This job doesn’t need a persisted write token. Set read-only permissions for the job and disable credential persistence on checkout.
🔐 Suggested workflow hardening
📝 Committable suggestion
🧰 Tools
🪛 zizmor (1.26.1)
[warning] 80-80: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
🤖 Prompt for AI Agents
Source: Linters/SAST tools