mirror of
https://github.com/sredevopsorg/deepseek-kubernetes-sandbox.git
synced 2026-11-03 01:13:24 +00:00
- Replace user:token cookies with opaque server-side sessions, revocable on logout, delete, recreate and expiry; bind every credential to the path user and add cross-user regression tests. - Rate-limit /users and /login, add optional signup invite codes and form same-origin checks, and unify login failures to 401. - Require explicit ALLOW_INSECURE_COOKIES for plain HTTP, use __Host-dsh_gw_session when secure, and fix secure cookie deletion. - Strip client-supplied forwarding/SSO headers, add an optional upstream allowlist, per-user in-flight and WebSocket message caps, credential-free handshake errors, and sweep-time state pruning. - Digest-pin base images, hash-pin gateway dependencies, verify DSH_COMMIT in the build, and run the gateway image as non-root with a pinned Python base. - Update manifests, production checklist, architecture/security docs and add an SSO preflight script. BREAKING CHANGE: existing dsh_gw_session=<user>:<token> cookies are invalid; users must sign in again. Unknown users on POST /login now return 401 instead of 404, and the gateway refuses COOKIE_SECURE=false unless ALLOW_INSECURE_COOKIES=1. Co-authored-by: SREDevOpsAgents <agents@sredevops.org>
87 lines
2.8 KiB
YAML
87 lines
2.8 KiB
YAML
# OPTIONAL for the base walkthrough, REQUIRED for production. Opt-in tenant
|
|
# network policy for the DSH sandboxes: without it every tenant can reach every
|
|
# other tenant and cluster-internal endpoints.
|
|
#
|
|
# It is NOT part of the top-level walkthrough. Apply and delete it explicitly:
|
|
# kubectl apply -f manifests/optional/network-policy/
|
|
# kubectl delete -f manifests/optional/network-policy/
|
|
#
|
|
# Production also needs the gateway egress policy (cluster-specific API-server
|
|
# endpoint) and the exposure variant's policy, plus gVisor
|
|
# (docs/optional-hardening.md#6-production-checklist).
|
|
#
|
|
# The selector uses the agent-sandbox controller's pod tracking label, which is
|
|
# present on every Sandbox pod (including warm-pool spares), so the policy
|
|
# applies to existing sandboxes without recreating them. The SandboxTemplate
|
|
# stays networkPolicyManagement: Unmanaged. Do not also switch it to Managed
|
|
# unless you migrate these rules into spec.networkPolicy; NetworkPolicies are
|
|
# additive and the two configurations would be confusing.
|
|
#
|
|
# Requires a CNI that enforces NetworkPolicy. See docs/optional-hardening.md
|
|
# for the connectivity matrix, DNS variants, kubelet-probe caveat and rollback.
|
|
apiVersion: networking.k8s.io/v1
|
|
kind: NetworkPolicy
|
|
metadata:
|
|
name: dsh-sandbox
|
|
namespace: dsh-demo
|
|
spec:
|
|
podSelector:
|
|
matchExpressions:
|
|
- key: agents.x-k8s.io/sandbox-name-hash
|
|
operator: Exists
|
|
policyTypes:
|
|
- Ingress
|
|
- Egress
|
|
ingress:
|
|
# The gateway is the only intended client of a sandbox (HTTP + WebSocket).
|
|
- from:
|
|
- podSelector:
|
|
matchLabels:
|
|
app: dsh-gateway
|
|
ports:
|
|
- protocol: TCP
|
|
port: 3080
|
|
egress:
|
|
# Cluster DNS. CoreDNS/kube-dns pods carry k8s-app=kube-dns.
|
|
- to:
|
|
- namespaceSelector:
|
|
matchLabels:
|
|
kubernetes.io/metadata.name: kube-system
|
|
podSelector:
|
|
matchLabels:
|
|
k8s-app: kube-dns
|
|
ports:
|
|
- protocol: UDP
|
|
port: 53
|
|
- protocol: TCP
|
|
port: 53
|
|
# NodeLocal DNSCache, for clusters that do not send DNS to the kube-dns
|
|
# Service. 169.254.20.10 is its standard link-local address.
|
|
- to:
|
|
- ipBlock:
|
|
cidr: 169.254.20.10/32
|
|
ports:
|
|
- protocol: UDP
|
|
port: 53
|
|
- protocol: TCP
|
|
port: 53
|
|
# Public HTTPS only: provider APIs, package mirrors, git-over-HTTPS.
|
|
# Private ranges, CGNAT and the metadata server stay blocked.
|
|
- to:
|
|
- ipBlock:
|
|
cidr: 0.0.0.0/0
|
|
except:
|
|
- 10.0.0.0/8
|
|
- 172.16.0.0/12
|
|
- 192.168.0.0/16
|
|
- 169.254.0.0/16
|
|
- 100.64.0.0/10
|
|
- ipBlock:
|
|
cidr: "::/0"
|
|
except:
|
|
- "fc00::/7"
|
|
- "fe80::/10"
|
|
ports:
|
|
- protocol: TCP
|
|
port: 443
|