-
Notifications
You must be signed in to change notification settings - Fork 0
fix oauth callback and integrate istio gateway with cert-manager for prod #25
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: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -37,22 +37,24 @@ spec: | |
| - browser-sandbox-gateway | ||
| http: | ||
| - match: | ||
| - uri: | ||
| prefix: "/api" | ||
| - headers: | ||
| ":authority": | ||
| exact: "api.kubebrowse1.ghcat.tech" | ||
| route: | ||
|
Comment on lines
+40
to
43
Contributor
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. Host/authority mismatch will prevent routing. You match on authority
Requests to Apply this diff (prefer the dedicated field over headers): - - headers:
- ":authority":
- exact: "api.kubebrowse1.ghcat.tech"
+ - authority:
+ exact: "api.kubebrowse1.ghcat.tech"Additionally (outside the changed hunk), update hosts: # Gateway.servers[*].hosts (both 80 and 443)
hosts:
- kubebrowse1.ghcat.tech
- api.kubebrowse1.ghcat.tech
- app.kubebrowse1.ghcat.tech
# VirtualService.spec.hosts
hosts:
- kubebrowse1.ghcat.tech
- api.kubebrowse1.ghcat.tech
- app.kubebrowse1.ghcat.tech🤖 Prompt for AI Agents |
||
| - destination: | ||
| host: browser-sandbox-api | ||
| port: | ||
| number: 4567 | ||
| - match: | ||
| - uri: | ||
| prefix: "/websocket" | ||
| - headers: | ||
| ":authority": | ||
| exact: "app.kubebrowse1.ghcat.tech" | ||
| route: | ||
| - destination: | ||
| host: browser-sandbox-api | ||
| host: browser-sandbox-frontend | ||
| port: | ||
| number: 4567 | ||
| - route: # Default route for frontend | ||
| number: 80 | ||
| - route: # Default route (fallback) | ||
| - destination: | ||
| host: browser-sandbox-frontend | ||
| port: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -253,6 +253,24 @@ spec: | |||||||||||||||||||||||||||||||||||||||||||
| app: browser-sandbox-api | ||||||||||||||||||||||||||||||||||||||||||||
| spec: | ||||||||||||||||||||||||||||||||||||||||||||
| serviceAccountName: browser-sandbox-sa | ||||||||||||||||||||||||||||||||||||||||||||
| initContainers: | ||||||||||||||||||||||||||||||||||||||||||||
| - name: cert-generator | ||||||||||||||||||||||||||||||||||||||||||||
| image: alpine:3.20 | ||||||||||||||||||||||||||||||||||||||||||||
| command: ['sh', '-c'] | ||||||||||||||||||||||||||||||||||||||||||||
| args: | ||||||||||||||||||||||||||||||||||||||||||||
| - | | ||||||||||||||||||||||||||||||||||||||||||||
| apk add --no-cache openssl | ||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p /app/certs | ||||||||||||||||||||||||||||||||||||||||||||
| echo "Generating self-signed certificates..." | ||||||||||||||||||||||||||||||||||||||||||||
| openssl req -x509 -nodes -days 365 -newkey rsa:2048 \ | ||||||||||||||||||||||||||||||||||||||||||||
| -keyout /app/certs/private.key \ | ||||||||||||||||||||||||||||||||||||||||||||
| -out /app/certs/certificate.crt \ | ||||||||||||||||||||||||||||||||||||||||||||
| -subj "/C=US/ST=California/L=San Francisco/O=My Company/CN=mydomain.com" | ||||||||||||||||||||||||||||||||||||||||||||
| echo "Certificates generated successfully" | ||||||||||||||||||||||||||||||||||||||||||||
| ls -la /app/certs/ | ||||||||||||||||||||||||||||||||||||||||||||
| volumeMounts: | ||||||||||||||||||||||||||||||||||||||||||||
| - name: certs-volume | ||||||||||||||||||||||||||||||||||||||||||||
| mountPath: /app/certs | ||||||||||||||||||||||||||||||||||||||||||||
| containers: | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+256
to
274
Contributor
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. Don’t generate self-signed TLS in initContainer for prod; use cert-manager/Issuers or terminate at Istio. This contradicts the PR goal and creates ephemeral, untrusted certs on each pod restart. If TLS terminates at the Istio Gateway, remove pod TLS entirely. Otherwise, mount a cert-manager-managed Secret. Apply (remove initContainer and cert volume): serviceAccountName: browser-sandbox-sa
- initContainers:
- - name: cert-generator
- image: alpine:3.20
- command: ['sh', '-c']
- args:
- - |
- apk add --no-cache openssl
- mkdir -p /app/certs
- echo "Generating self-signed certificates..."
- openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
- -keyout /app/certs/private.key \
- -out /app/certs/certificate.crt \
- -subj "/C=US/ST=California/L=San Francisco/O=My Company/CN=mydomain.com"
- echo "Certificates generated successfully"
- ls -la /app/certs/
- volumeMounts:
- - name: certs-volume
- mountPath: /app/certsAnd also remove the related env, volumeMount, and volume below (see next comments). 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
| - name: api | ||||||||||||||||||||||||||||||||||||||||||||
| image: ghcr.io/browsersec/kubebrowse:sha-09dfa1f | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -320,15 +338,15 @@ spec: | |||||||||||||||||||||||||||||||||||||||||||
| - name: DISTRIBUTED_TRACING | ||||||||||||||||||||||||||||||||||||||||||||
| value: "true" | ||||||||||||||||||||||||||||||||||||||||||||
| - name: GITHUB_CLIENT_ID | ||||||||||||||||||||||||||||||||||||||||||||
| value: "Ov23li974J8UoG1CH0HJ" | ||||||||||||||||||||||||||||||||||||||||||||
| value: "Ov23liQQQ5lMyIrOULYx" | ||||||||||||||||||||||||||||||||||||||||||||
| - name: GITHUB_CLIENT_SECRET | ||||||||||||||||||||||||||||||||||||||||||||
| value: "f16b7dc2b85d4a7f817e273b4a2d64124153ce8f" | ||||||||||||||||||||||||||||||||||||||||||||
| value: "47afea55e0e19231e1cc82c3a57d56aaeedb480e" | ||||||||||||||||||||||||||||||||||||||||||||
| - name: GITHUB_CALLBACK_URL | ||||||||||||||||||||||||||||||||||||||||||||
| value: "https://localhost:4567/auth/oauth/github/callback" | ||||||||||||||||||||||||||||||||||||||||||||
| - name: SESSION_SECRET | ||||||||||||||||||||||||||||||||||||||||||||
| value: "McX0xoYlJYpO0EGdUZC6aJxVh2rKYrXZM7SPMpVREeXMXoMBI20v90PICD-LfEn7jr07c5vH2CWcKzjl8hoNvQ" | ||||||||||||||||||||||||||||||||||||||||||||
| - name: FRONTEND_URL | ||||||||||||||||||||||||||||||||||||||||||||
| value: "http://localhost:5173" | ||||||||||||||||||||||||||||||||||||||||||||
| value: "http://localhost:8080" | ||||||||||||||||||||||||||||||||||||||||||||
| - name: ENVIRONMENT | ||||||||||||||||||||||||||||||||||||||||||||
| value: "development" | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
345
to
351
Contributor
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. 🛠️ Refactor suggestion Fix OAuth callback and environment for prod.
Apply: - - name: GITHUB_CALLBACK_URL
- value: "https://localhost:4567/auth/oauth/github/callback"
+ - name: GITHUB_CALLBACK_URL
+ value: "https://<your-domain>/auth/oauth/github/callback"
...
- - name: ENVIRONMENT
- value: "development"
+ - name: ENVIRONMENT
+ value: "production"Also ensure the GitHub OAuth app is updated with the same callback URL. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
| - name: SMTP_HOST | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -341,11 +359,17 @@ spec: | |||||||||||||||||||||||||||||||||||||||||||
| value: "ulagdeliigobhdgr" | ||||||||||||||||||||||||||||||||||||||||||||
| - name: FROM_EMAIL | ||||||||||||||||||||||||||||||||||||||||||||
| value: "sanjay.obsidian@gmail.com" | ||||||||||||||||||||||||||||||||||||||||||||
| # - name: CERT_PATH | ||||||||||||||||||||||||||||||||||||||||||||
| # value: "" | ||||||||||||||||||||||||||||||||||||||||||||
| # - name: CERT_KEY_PATH | ||||||||||||||||||||||||||||||||||||||||||||
| # value: "" | ||||||||||||||||||||||||||||||||||||||||||||
| - name: CERT_PATH | ||||||||||||||||||||||||||||||||||||||||||||
| value: "/app/certs/certificate.crt" | ||||||||||||||||||||||||||||||||||||||||||||
| - name: CERT_KEY_PATH | ||||||||||||||||||||||||||||||||||||||||||||
| value: "/app/certs/private.key" | ||||||||||||||||||||||||||||||||||||||||||||
| volumeMounts: | ||||||||||||||||||||||||||||||||||||||||||||
| - name: certs-volume | ||||||||||||||||||||||||||||||||||||||||||||
| mountPath: /app/certs | ||||||||||||||||||||||||||||||||||||||||||||
| securityContext: {} | ||||||||||||||||||||||||||||||||||||||||||||
| volumes: | ||||||||||||||||||||||||||||||||||||||||||||
| - name: certs-volume | ||||||||||||||||||||||||||||||||||||||||||||
| emptyDir: {} | ||||||||||||||||||||||||||||||||||||||||||||
| --- | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+362
to
373
Contributor
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. 🛠️ Refactor suggestion Remove CERT_PATH/CERT_KEY and the cert volume if TLS terminates at the gateway. Or replace with cert-manager Secret. Mounting ephemeral certs is brittle. Option A (Gateway TLS termination, recommended): - - name: CERT_PATH
- value: "/app/certs/certificate.crt"
- - name: CERT_KEY_PATH
- value: "/app/certs/private.key"
- volumeMounts:
- - name: certs-volume
- mountPath: /app/certs
...
- volumes:
- - name: certs-volume
- emptyDir: {}Option B (pod TLS via cert-manager):
+ volumeMounts:
+ - name: api-tls
+ mountPath: /app/certs
+ readOnly: true
...
+ volumes:
+ - name: api-tls
+ secret:
+ secretName: api-tlsAnd keep 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Checkov (3.2.334)[MEDIUM] 240-373: Containers should not run with allowPrivilegeEscalation (CKV_K8S_20) [MEDIUM] 240-373: Minimize the admission of root containers (CKV_K8S_23) |
||||||||||||||||||||||||||||||||||||||||||||
| # API Service | ||||||||||||||||||||||||||||||||||||||||||||
| apiVersion: v1 | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
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.
🛠️ Refactor suggestion
Avoid syncing /app/certs; it can overwrite init-generated certs at runtime.
The initContainer is responsible for generating certs. Live-update syncing this path risks clobbering keys/certs and breaking TLS.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents