diff --git a/AGENTS.md b/AGENTS.md index e3d6e66..ac448c8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -136,9 +136,6 @@ unless the architecture itself has intentionally changed. Use the repository's current architecture and operational documentation as the source of truth for ownership, protocols, and system behavior. -Historical material under `docs/legacy/` is archival and must not be treated as -current system behavior. - Record significant architectural decisions in the appropriate ADR or Brain documentation rather than expanding this file into an architecture manual. diff --git a/docs/legacy/adr-001-remove-localhost-routers.md b/docs/legacy/adr-001-remove-localhost-routers.md deleted file mode 100644 index d87731d..0000000 --- a/docs/legacy/adr-001-remove-localhost-routers.md +++ /dev/null @@ -1,36 +0,0 @@ -# ADR 001: Removal of Localhost Routers for Development Freedom - -* **Status**: Accepted & Implemented -* **Date**: 2026-05-17 -* **Decider**: User & Gemini CLI - -## Context -Initially, we implemented `*.localhost` routers in Traefik to allow local access to services (e.g., `jellyfin.localhost`) without traversing the public internet. The goal was to provide a "fast lane" for local management. - -However, two major technical hurdles were encountered: -1. **SSL/TLS Restrictions**: Public Certificate Authorities (like Let's Encrypt) cannot issue certificates for the `.localhost` TLD. This resulted in "Insecure" warnings in browsers and the need to manage a local CA (like `mkcert`) or accept self-signed certificates. -2. **SSO (Cookie) Limitations**: Browsers enforce strict domain matching for cookies. Our Authelia instance is configured for `arch-services.mywire.org`. Browsers refuse to send these session cookies to `*.localhost` domains. This caused an infinite redirect loop or authentication errors when accessing services locally. -3. **Namespace Pollution**: Using `*.localhost` in Traefik intercepts traffic that might be needed for other developer workflows (e.g., running undeployed apps, Vite dev servers, or testing environments that default to `localhost`). - -## Decision -We decided to **deprecate and remove all `*.localhost` routers** from the Traefik configuration across all services. - -Instead of dedicated local hostnames, we will use the **Public Domain + Local IP** strategy for local access. - -## Consequences - -### Positive -* **Seamless SSO**: Authelia SSO works perfectly because the browser sees the public domain (`*.arch-services.mywire.org`) and sends the correct cookies. -* **Valid SSL**: Traefik serves the real Let's Encrypt wildcard certificate, providing "Green Lock" security in browsers without manual certificate management. -* **Clean Namespace**: The `.localhost` TLD is now entirely free for other developer-specific tools and testing. -* **Local Speed**: When configured correctly via `/etc/hosts`, traffic never leaves the local machine, maintaining the speed benefits of the previous implementation. - -### Negative / Required Actions -* **Manual Configuration**: Users must manually update their machine's `/etc/hosts` file to point the public subdomains to `127.0.0.1`. -* **SSO Requirement**: Local access now requires the same Authelia authentication as public access (unless explicitly bypassed in the public router, which is not recommended for security). - -## Implementation Detail -To access services locally with this architecture, add the following to your `/etc/hosts`: -```text -127.0.0.1 traefik.arch-services.mywire.org auth.arch-services.mywire.org jellyfin.arch-services.mywire.org gitea.arch-services.mywire.org excalidraw.arch-services.mywire.org homepage.arch-services.mywire.org mermaid.arch-services.mywire.org ollama.arch-services.mywire.org learning.arch-services.mywire.org logs.arch-services.mywire.org portainer.arch-services.mywire.org -``` diff --git a/docs/legacy/adr-002-migrate-dynu-discovery-to-nixos.md b/docs/legacy/adr-002-migrate-dynu-discovery-to-nixos.md deleted file mode 100644 index 0853351..0000000 --- a/docs/legacy/adr-002-migrate-dynu-discovery-to-nixos.md +++ /dev/null @@ -1,32 +0,0 @@ -# ADR 002: Migrate Dynu DDNS IP Discovery to Host NixOS Configuration - -* **Status**: Accepted & Implemented -* **Date**: 2026-06-24 -* **Decider**: User & Antigravity - -## Context -Previously, we managed dynamic DNS IP synchronization using custom bash scripts (`ip-monitor.sh`) and systemd unit configurations in the `homeserver` scripts directory. The service checked the WAN IP and pushed updates to Dynu every 5 minutes. - -However, this design introduced several structural problems: -1. **Imperative Secrets Leakage**: Credentials were stored in a cleartext out-of-band environment file (`/etc/conf.d/dynu-environment`). This required manual setup on target hosts and broke the declarative reproducibility goal. -2. **Redundant Logic**: The desktop machine (`desktop`) and server machine shared the same router (external public IP), but operated separate, duplicated cron/timer implementations. -3. **Inefficient Polling**: Checking the external IP and calling the Dynu APIs every 5 minutes from multiple endpoints generated unnecessary network traffic and risked API bans. - -## Decision -We decided to **deprecate and remove all native Dynu IP updater scripts and systemd definitions** from the `homeserver` codebase. - -Instead, the Dynu IP monitoring and DDNS update lifecycle is now managed directly by the host operating system's configuration repository ([nixos-config](https://github.com/kiskaadee/nixos-config)). - -## Consequences - -### Positive -* **Single Source of Truth**: All WAN IP discovery, validation, and update logic is handled declaratively in the [nixos-config](https://github.com/kiskaadee/nixos-config) repository. -* **Cryptographic Secrets**: Credentials are encrypted inside Git using `sops-nix` and `age`, allowing safe storage in public dotfiles repositories. -* **Smart Change Detection**: A lightweight background Python script (`monitor.py`) checks the public IP every 30 minutes, keeping a local historical log (`ip_history.jsonl`) and triggering updates via `ddclient` *only* when a WAN IP rotation actually occurs. -* **Clean Repository**: Removed bloat and deprecated files from this service-level repo. - -### Negative / Required Actions -* None. The deployment process is simplified as secrets and services are now handled automatically during the system-wide NixOS activation phase. - -## References -* This decision was implemented in the [nixos-config commits](https://github.com/kiskaadee/nixos-config/commits/main/) under hash `c7acc2b0a3bb262dfd5577989d8d7f0218f2721e` (and subsequent hardening adjustments). diff --git a/docs/legacy/architecture.html b/docs/legacy/architecture.html deleted file mode 100644 index 0498b32..0000000 --- a/docs/legacy/architecture.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - Server Architecture | Hardened Hub - - - - -
-
-

πŸ—οΈ Server Architecture

-

Model: Hardened Hub v2.0

-
- - - -

The homeserver follows a Layered Architecture designed for security, observability, and modularity. It is split into two logical tiers: the Control Plane (Infrastructure) and the Data Plane (Applications).

- -
-

1. Physical & Host Layer

-

The foundation of the system running directly on the host hardware or virtualized OS.

-
-
    -
  • OS: Linux (Generic).
  • -
  • IP Sync: [DEPRECATED/MOVED] Dynu DDNS updates are now handled declaratively by the host's NixOS configuration repository (nixos-config).
  • -
  • Docker Engine: Orchestrates all containerized services.
  • -
-
-
- -
-

2. Infrastructure Layer (Control Plane)

-

The management tier that handles routing, identity, and system maintenance.

- -
-
-

🌐 Edge Gateway

-

Traefik v3: Reverse Proxy & SSL (DNS-01 Challenges). Routes subdomains for all core and user-deployed services.

-
-
-

πŸ” Identity

-

Authelia: SSO & 2FA provider. Forward Auth integration with Traefik.

-
-
-

πŸ›‘οΈ Socket Proxy

-

Protects the Docker socket from container-escape vulnerabilities.

-
-
-

πŸ› οΈ Maintenance

-

Portainer (Management), Watchtower (Updates), and Diun (Notifications).

-
-
-
- -
-

3. Application Layer (Data Plane)

-

Consumer-facing services isolated from the core infrastructure.

-
-
    -
  • Service Discovery: Homepage dashboard serves as a unified entry portal.
  • -
  • SSO Protection: Critical administration pages and external services utilize Authelia Forward Auth.
  • -
  • Decoupled Lifecycles: User applications run in separate containers outside this repository, keeping the core system clean and stable.
  • -
  • Isolation: Services have no direct host access and communicate strictly over dynamic internal networks.
  • -
-
-
- - -
-

4. Networking Model

-

Traffic flow is segmented to minimize the blast radius of a potential breach.

- -
- -
-

πŸ›‘οΈ Security Posture

-

Current hardening measures enforced across the Hub:

- -
- - -
- - - diff --git a/docs/legacy/dynu-ip-update-protocol.html b/docs/legacy/dynu-ip-update-protocol.html deleted file mode 100644 index b73ea21..0000000 --- a/docs/legacy/dynu-ip-update-protocol.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - Dynu IP Protocol | Hardened Hub - - - - -
-
- ⚠️ DEPRECATED -

This script-based DDNS implementation has been deprecated and removed from the homeserver repository. The Dynamic DNS update service and IP monitor are now handled declaratively by the host's NixOS configuration repository. See the nixos-config repository commit c7acc2b0a3b for implementation details.

-
- -
-

πŸ“‘ Dynu IP Monitor & Updater

-

Design and architecture of the DDNS synchronization mechanism.

-
- -
-

Problem Definition

-

Maintain accurate DNS A records despite dynamic public IPs and unreliable providers.

-
- -
-

Core Design Decisions

-
-
-

1. Probe Model

-

Runs periodically via systemd instead of a long-lived daemon.

-
-
-

2. Dual-Source

-

Uses DNS (primary) and HTTP (fallback) for IP discovery.

-
-
-

3. Validation

-

Strict pipeline ensures no RFC1918 or private IPs are ever synced.

-
-
-

4. Atomicity

-

State updates use atomic file moves to prevent corruption.

-
-
-
- -
-

Failure Model

- -
- - -
- - - diff --git a/docs/legacy/index.html b/docs/legacy/index.html deleted file mode 100644 index 8fd5432..0000000 --- a/docs/legacy/index.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - Documentation | Hardened Hub - - - - -
-
-

πŸ“š Documentation Hub

-

Hardened Private Cloud Architecture & Operations

-
- -
-

Guides & Architecture

-
-
-

πŸ—οΈ Server Architecture

-

Deep dive into the layered model, networking, and security posture.

-
- -
-

🩺 Troubleshooting

-

Solutions for common connectivity, SSL, and authentication issues.

-
-
-

πŸ—ΊοΈ Project Roadmap

-

Current status and future planned features.

-
-
-

πŸ“‘ Dynu IP Protocol

-

Technical details on the DDNS synchronization mechanism.

-
-
-
- - -
- - - diff --git a/docs/legacy/roadmap.html b/docs/legacy/roadmap.html deleted file mode 100644 index e1a2b1b..0000000 --- a/docs/legacy/roadmap.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - Project Roadmap | Hardened Hub - - - - -
-
-

πŸ—ΊοΈ Project Roadmap

-

Current system maturity and future priorities for the core infrastructure.

-
- - - -
-

βœ… Phase 1: Core Gateway & Infrastructure

-

COMPLETE Stable external access, identity management, and core security.

- -
- -
-

πŸ—οΈ Phase 2: Observability & Portal Layer

-

IN PROGRESS Expand utility and improve system monitoring.

- -
- -
-

πŸš€ Phase 3: Automation & Resilience

- -
- -
-

🌐 Phase 4: Network Optimization

- -
- - -
- - - diff --git a/docs/legacy/style.css b/docs/legacy/style.css deleted file mode 100644 index 70f1a77..0000000 --- a/docs/legacy/style.css +++ /dev/null @@ -1,103 +0,0 @@ -:root { - --primary: #2563eb; - --secondary: #475569; - --bg: #f8fafc; - --text: #1e293b; - --border: #e2e8f0; - --accent: #f1f5f9; - --success: #166534; - --success-bg: #dcfce7; - --warning: #9a3412; - --warning-bg: #ffedd5; -} - -body { - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; - line-height: 1.6; - color: var(--text); - background: var(--bg); - margin: 0; - padding: 2rem; -} - -main { - max-width: 900px; - margin: 0 auto; - background: white; - padding: 3rem; - border-radius: 8px; - box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); -} - -header { - border-bottom: 2px solid var(--border); - margin-bottom: 2rem; - padding-bottom: 1rem; -} - -h1 { font-size: 2.5rem; color: var(--primary); margin: 0; } -h2 { font-size: 1.75rem; color: var(--secondary); margin-top: 2.5rem; border-left: 4px solid var(--primary); padding-left: 1rem; } -h3 { font-size: 1.25rem; color: var(--text); margin-top: 1.5rem; } - -code { - background: var(--accent); - padding: 0.2rem 0.4rem; - border-radius: 4px; - font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; - font-size: 0.9em; -} - -pre { - background: #1e293b; - color: #f8fafc; - padding: 1.5rem; - border-radius: 6px; - overflow-x: auto; -} - -pre code { - background: transparent; - padding: 0; - color: inherit; -} - -.layer-box { - background: var(--accent); - padding: 1.5rem; - border-radius: 6px; - margin: 1rem 0; - border: 1px solid var(--border); -} - -nav { - background: var(--accent); - padding: 1rem; - border-radius: 6px; - margin-bottom: 2rem; -} - -nav h4 { margin: 0 0 0.5rem 0; font-size: 0.9rem; text-transform: uppercase; color: var(--secondary); } -nav ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.9rem; } -nav a { color: var(--primary); text-decoration: none; } -nav a:hover { text-decoration: underline; } - -.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; } -.card { border: 1px solid var(--border); padding: 1rem; border-radius: 4px; background: white; } -.card h4 { margin: 0 0 0.5rem 0; color: var(--primary); } - -.badge { - padding: 0.2rem 0.6rem; - border-radius: 9999px; - font-size: 0.8rem; - font-weight: bold; - display: inline-block; -} - -.badge-success { background: var(--success-bg); color: var(--success); } -.badge-warning { background: var(--warning-bg); color: var(--warning); } - -.status-list { list-style: none; padding: 0; } -.status-item { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; } - -footer { margin-top: 4rem; font-size: 0.8rem; color: var(--secondary); text-align: center; border-top: 1px solid var(--border); padding-top: 2rem; } -footer a { color: var(--primary); text-decoration: none; } diff --git a/docs/legacy/troubleshooting.html b/docs/legacy/troubleshooting.html deleted file mode 100644 index 8855fdc..0000000 --- a/docs/legacy/troubleshooting.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - Troubleshooting | Hardened Hub - - - - -
-
-

🩺 Troubleshooting Guide

-

Common issues and resolutions for the Hardened Hub.

-
- - - -
-

🌐 Connectivity Issues

-
-

Site is unreachable

-
    -
  • Check External IP: Verify your public IP matches Dynu.
  • -
  • Check Traefik: docker compose -f infra/core/docker-compose.yml ps
  • -
-
-
-

Bad Gateway (502/503)

-

The application is down or not on proxy-net.

-
-
- -
-

πŸ”’ SSL & Certificate Issues

-

If you see "Connection not private", Traefik may be failing the ACME challenge.

- -
-

Dynu Quota Deadlock (Record Hoarding)

-

On the Dynu free tier (4-record limit), failed challenges can leave stale TXT records that block new attempts with a 503: Quota Exception.

-

Fix: Run the automated purge script to clear stale records and restart the challenge:

-
./scripts/purge-dynu.sh
-
- -
-

Manual Inspection

-
# Check Traefik ACME logs
-docker compose -f infra/core/docker-compose.yml logs -f traefik
-
-# Run automated SSL diagnostic
-./scripts/check-ssl.sh
-
-
- -
-

πŸ” Authentication (Authelia)

-
-

Stuck in Login Loop?

-

Sync server time: sudo ntpdate pool.ntp.org and clear cookies.

-
-
- -
-

🐳 Docker & Performance

-

If disk is full, run cleanup:

-
docker system prune -a --volumes
-
- - -
- - - diff --git a/docs/legacy/usability.html b/docs/legacy/usability.html deleted file mode 100644 index 8f983fb..0000000 --- a/docs/legacy/usability.html +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - Usability & Operations | Hardened Hub - - - - -
-
-

πŸ–±οΈ Usability & Operational Notes

-

A guide for interacting with the Hardened Hub and exposing external services.

-
- - - -
-

πŸ”‘ Authentication (SSO)

-

Critical core services and protected user applications are shielded by Authelia.

-
    -
  1. Access a protected URL (e.g., https://portainer.arch-services.mywire.org).
  2. -
  3. You will be redirected to the Auth Portal (https://auth.arch-services.mywire.org).
  4. -
  5. Log in with your credentials.
  6. -
  7. Once authenticated, you obtain global session access to all SSO-protected services.
  8. -
-
- - - -
-

πŸ› οΈ Core Infrastructure Management

-

Deploy the control plane stacks and homepage directly using the host scripts:

-
# Start the Control Plane + Homepage Portal
-./up.sh
-
-# Stop all Core services
-./down.sh
-
- -
-

βž• Exposing a New Service (Decoupled Model)

-

User applications are fully decoupled from the core repository and managed in their own directories (e.g., /home/kiskaadee/deployments/my-app). We use Traefik labels to expose them under the *.arch-services.mywire.org wildcard domain.

- -

Depending on your security and access needs, you can configure your stack for one of two scenarios:

- -
-
-

πŸ”“ Scenario A: Public / Direct Access

-

Use this for applications that have their own built-in authentication (e.g., Jellyfin, Gitea) or public-facing projects (e.g., public web demos, portfolios).

-
-
-

πŸ”’ Scenario B: SSO-Protected

-

Use this for administrative tools, private databases, or custom internal apps that do not have native authentication and need to be secured behind Authelia.

-
-
- -
- -

Scenario A: Public / Direct Access (Bypassing Authelia)

-

This configuration exposes your service directly to the internet. Authelia is bypassed, allowing anyone (or the app's own login manager) to handle access.

- -
services:
-  my-public-app:
-    image: my-app-image:latest
-    container_name: my-public-app
-    networks:
-      - proxy-net
-    labels:
-      - "traefik.enable=true"
-      
-      # 1. Main HTTPS Route Rule
-      - "traefik.http.routers.public-app.rule=Host(`demo.arch-services.mywire.org`)"
-      - "traefik.http.routers.public-app.entrypoints=websecure"
-      - "traefik.http.routers.public-app.tls=true"
-      - "traefik.http.routers.public-app.service=public-app-svc"
-
-      # 2. HTTP to HTTPS Redirection Route
-      - "traefik.http.routers.public-app-red.rule=Host(`demo.arch-services.mywire.org`)"
-      - "traefik.http.routers.public-app-red.entrypoints=web"
-      - "traefik.http.routers.public-app-red.middlewares=https-redirect@docker"
-
-      # 3. Port Mapping (Target port inside the container)
-      - "traefik.http.services.public-app-svc.loadbalancer.server.port=8080"
-
-networks:
-  proxy-net:
-    external: true
- -

Scenario B: SSO-Protected (Secured by Authelia)

-

This configuration intercepts all incoming requests and redirects unauthenticated users to the Authelia portal first. Once logged in, users are returned to the service.

- -
services:
-  my-secure-app:
-    image: my-app-image:latest
-    container_name: my-secure-app
-    networks:
-      - proxy-net
-    labels:
-      - "traefik.enable=true"
-      
-      # 1. Main HTTPS Route Rule
-      - "traefik.http.routers.secure-app.rule=Host(`admin.arch-services.mywire.org`)"
-      - "traefik.http.routers.secure-app.entrypoints=websecure"
-      - "traefik.http.routers.secure-app.tls=true"
-      - "traefik.http.routers.secure-app.service=secure-app-svc"
-
-      # 2. SSO Authentication Middleware (Crucial Line)
-      - "traefik.http.routers.secure-app.middlewares=authelia-auth@docker"
-
-      # 3. HTTP to HTTPS Redirection Route
-      - "traefik.http.routers.secure-app-red.rule=Host(`admin.arch-services.mywire.org`)"
-      - "traefik.http.routers.secure-app-red.entrypoints=web"
-      - "traefik.http.routers.secure-app-red.middlewares=https-redirect@docker"
-
-      # 4. Port Mapping (Target port inside the container)
-      - "traefik.http.services.secure-app-svc.loadbalancer.server.port=3000"
-
-networks:
-  proxy-net:
-    external: true
- -

3. Register in Homepage Dashboard

-

To list your new service on the central dashboard, update homepage/config/services.yaml inside the core repository:

-
- User Applications:
-    - My Application:
-        icon: custom-app-icon
-        href: https://my-app.arch-services.mywire.org
-        description: Custom exposed app description
-        server: my-docker
-        container: my-app # Must match container_name exactly
-
- - -
- - - diff --git a/tests/structural/test_repository_structure.py b/tests/structural/test_repository_structure.py index 0d58e67..f971683 100644 --- a/tests/structural/test_repository_structure.py +++ b/tests/structural/test_repository_structure.py @@ -48,6 +48,7 @@ def test_deprecated_legacy_structures_are_absent(): "scripts/check-ssl.sh", "scripts/purge-dynu.sh", "scripts/ip-monitor.sh", + "docs/legacy", ] for p in prohibited_paths: