Skip to content

feat(backend): close public access and allow only in-cluster callers - #28

Open
BIA3IA wants to merge 1 commit into
mainfrom
feat/backend-phase6-network
Open

BIA3IA wants to merge 1 commit into
mainfrom
feat/backend-phase6-network

Conversation

@BIA3IA

@BIA3IA BIA3IA commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Summary

RFC v3 Phase 6 (§12) for the backend deployment.

  • Removes apps/backend/ingress.yaml. api.polinetwork.org and backend.polinetwork.org no longer reach the backend. Every caller uses the in-cluster Service (backend-service.backend.svc.cluster.local:3000):

    Caller Uses it for
    admin BACKEND_URL, also for the esign agent proxy
    web BACKEND_URL
    bot-ts BACKEND_URL, for tRPC and the socket
    auth OAUTH_BACKEND_EVENTS_URL

    The only thing that needed the public hostnames was the backend's better-auth, which feat(auth)!: drop better-auth and the legacy permission tables (RFC v3 Phase 6) backend#93 removes.

  • Adds apps/backend/network-policy.yaml. It allows ingress to app: backend only from app: admin, app: web, app: bot-ts and app: auth in their namespaces, on TCP 3000. Redis sidecars and Traefik are excluded. Kubelet TCP probes are not affected. The policy follows the style of infrastructure/flux-web/network-policy.yaml. The cluster enforces it through the k3s network policy controller.

  • Removes PUBLIC_URL, TRUSTED_ORIGINS and BETTER_AUTH_SECRET, which only better-auth read. Also removes GITHUB_CLIENT_ID / GITHUB_CLIENT_SECRET, which the backend no longer reads at all, and their azure-kv mappings.

Order: merge after PoliNetworkOrg/backend#93 is running

The backend image currently in production still requires BETTER_AUTH_SECRET. If this PR rolls out first, the pod restarts on the old image and fails at startup.

  1. Back up the DB and merge feat(auth)!: drop better-auth and the legacy permission tables (RFC v3 Phase 6) backend#93. Flux deploys the new latest digest.
  2. Check that the backend pod is running the new image and that the migration ran ([DB] Migration completed).
  3. Merge this PR.

Outside git (manual)

  • Cloudflare Zero Trust: remove the public hostnames api.polinetwork.org and backend.polinetwork.org from the k3s01 tunnel, and their DNS records. Until then the requests reach Traefik and get a 404.
  • Uptime Kuma: if a monitor watches api.polinetwork.org, remove it or point it elsewhere.
  • Key Vault: backend-auth-secret, backend-auth-github-id and backend-auth-github-secret are no longer used and can be deleted.

Verification

  • kustomize build apps/backend (v5.4.3): Namespace, Service, Deployment, ExternalSecret, NetworkPolicy.
  • kubeconform -strict: the 4 core resources are valid. ExternalSecret has no schema, since it is a CRD.
  • ruby tests/workload-manifests.test.rb: passed.

Not verified: the policy against the live cluster, because I have no cluster access. After the merge, check that admin, web, the bot and the IdP events still reach the backend.

RFC v3 Phase 6 (§12). Every caller reaches the backend in-cluster, and
the backend has no login of its own anymore:

- remove the Ingress for api.polinetwork.org and backend.polinetwork.org
- add a NetworkPolicy that admits only admin, web, bot-ts and auth on
  port 3000
- drop PUBLIC_URL, TRUSTED_ORIGINS, BETTER_AUTH_SECRET and the unused
  GITHUB_CLIENT_* settings, and their Key Vault mappings
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a69b8fda-580e-4b18-b5ae-8e7b55d3b615
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant