mirror of
https://github.com/sredevopsorg/deepseek-kubernetes-sandbox.git
synced 2026-11-03 01:13:24 +00:00
Add oauth2-proxy (GitHub provider, org-restricted) as a reverse proxy in front of the dsh-gateway, wired through the Traefik Gateway API. The gateway inherits the authenticated GitHub username via X-Forwarded-User (SSO). - gateway.py: opt-in AUTH_PROXY_HEADER trust, remote_user(), SSO bootstrap (auto-provision claim + mint/rotate token + session cookie), patch_token() - 50-gateway.yaml: AUTH_PROXY_HEADER=X-Forwarded-User, COOKIE_SECURE=true - gateway-api/dsh-demo: oauth2-proxy Deployment/Service + secret example, HTTPRoute backend -> oauth2-proxy:4180 - tests: 10 new SSO cases (106 passing) Placeholders (dsh-demo.example.com, your-github-org) are substituted at apply time. Co-authored-by: SREDevOpsAgents <agents@sredevops.org>
120 lines
3.6 KiB
YAML
120 lines
3.6 KiB
YAML
# oauth2-proxy — GitHub OAuth login in front of the dsh-gateway.
|
|
#
|
|
# Runs as a reverse proxy: it authenticates the browser against GitHub
|
|
# (restricted to a configured organization), then forwards the request to
|
|
# the dsh-gateway Service with the authenticated identity in X-Forwarded-User
|
|
# (plus X-Auth-Request-* via --set-xauthrequest). The gateway trusts that
|
|
# header (AUTH_PROXY_HEADER) to inherit the username (SSO).
|
|
#
|
|
# Credentials come from the "oauth2-proxy" Secret (see
|
|
# oauth2-proxy-secret.yaml.example); this manifest never carries secrets.
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: oauth2-proxy
|
|
namespace: dsh-demo
|
|
labels:
|
|
app: oauth2-proxy
|
|
app.kubernetes.io/part-of: dsh-demo
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: oauth2-proxy
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: oauth2-proxy
|
|
app.kubernetes.io/part-of: dsh-demo
|
|
spec:
|
|
securityContext:
|
|
runAsNonRoot: true
|
|
runAsUser: 2000
|
|
runAsGroup: 2000
|
|
seccompProfile:
|
|
type: RuntimeDefault
|
|
containers:
|
|
- name: oauth2-proxy
|
|
image: quay.io/oauth2-proxy/oauth2-proxy:v7.15.5
|
|
imagePullPolicy: IfNotPresent
|
|
securityContext:
|
|
allowPrivilegeEscalation: false
|
|
readOnlyRootFilesystem: true
|
|
capabilities:
|
|
drop: ["ALL"]
|
|
args:
|
|
- --http-address=0.0.0.0:4180
|
|
- --provider=github
|
|
# TODO: replace with the GitHub organization allowed to sign in.
|
|
- --github-org=your-github-org
|
|
- --email-domain=*
|
|
# Reverse-proxy target: the gateway backend Service.
|
|
- --upstream=http://dsh-gateway:8080
|
|
# Public callback (TLS terminates at the Gateway listener).
|
|
# TODO: replace with the actual public FQDN.
|
|
- --redirect-url=https://dsh-demo.example.com/oauth2/callback
|
|
- --cookie-secure=true
|
|
- --cookie-name=_oauth2_proxy
|
|
# Also expose X-Auth-Request-User/Email/Groups upstream.
|
|
- --set-xauthrequest
|
|
# Single provider: skip the provider-selection page.
|
|
- --skip-provider-button
|
|
env:
|
|
- name: OAUTH2_PROXY_CLIENT_ID
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: oauth2-proxy
|
|
key: client-id
|
|
- name: OAUTH2_PROXY_CLIENT_SECRET
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: oauth2-proxy
|
|
key: client-secret
|
|
- name: OAUTH2_PROXY_COOKIE_SECRET
|
|
valueFrom:
|
|
secretKeyRef:
|
|
name: oauth2-proxy
|
|
key: cookie-secret
|
|
ports:
|
|
- name: http
|
|
containerPort: 4180
|
|
livenessProbe:
|
|
httpGet:
|
|
path: /ping
|
|
port: http
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 10
|
|
timeoutSeconds: 1
|
|
failureThreshold: 3
|
|
readinessProbe:
|
|
httpGet:
|
|
path: /ready
|
|
port: http
|
|
initialDelaySeconds: 5
|
|
periodSeconds: 10
|
|
timeoutSeconds: 5
|
|
failureThreshold: 3
|
|
resources:
|
|
requests:
|
|
cpu: 10m
|
|
memory: 32Mi
|
|
limits:
|
|
cpu: 200m
|
|
memory: 128Mi
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: oauth2-proxy
|
|
namespace: dsh-demo
|
|
labels:
|
|
app: oauth2-proxy
|
|
app.kubernetes.io/part-of: dsh-demo
|
|
spec:
|
|
selector:
|
|
app: oauth2-proxy
|
|
ports:
|
|
- name: http
|
|
port: 4180
|
|
targetPort: http
|