Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions federation-shared.example.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# FEDERATION_SYNC_DRF_TOKEN: DRF Token for GET /users/get-federation-sync-api-key/ (required).
# FEDERATION_SYNC_SERVER_API_KEY: optional export Api-Key override. When empty, the sync
# service mints one at startup via the DRF token and caches it in-process.
# FEDERATION_SYNC_ADMIN_TOKEN: Bearer token for sync /internal/registry/* (gateway staff UI).
# Generated by gateway/scripts/generate-secrets.sh into this file.
# NOT for applicant domain verify — that uses FEDERATION_REGISTRY_CHALLENGE_TOKEN on the
# applicant's sync (.env.peer) or gateway (django.env); see federation/env.peer.example.

FEDERATION_SYNC_DRF_TOKEN=
FEDERATION_SYNC_SERVER_API_KEY=
FEDERATION_SYNC_ADMIN_TOKEN=
9 changes: 9 additions & 0 deletions federation/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,14 @@ federation.toml
federation.peer.toml
site.env

# Registry signing key (flagship sync) — see secrets/registry/README.md
secrets/registry/sign.pem
secrets/registry/*.pem
!secrets/registry/README.md
!secrets/registry/.gitkeep

# Local live-test secrets only (keep README + env.example tracked)
scripts/local_e2e/.env
.env.peer
.env.local
peer.env
40 changes: 35 additions & 5 deletions federation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Set `[site].sync_service_url` / `FEDERATION_SYNC_SERVICE_URL` to that public HTT
(not `:8001`). Production compose loads sync URL and related vars from gitignored
`site.env` (see `site.example.env`).

See also: [scripts/local_e2e/README.md](scripts/local_e2e/README.md),
See also: [docs/federation-registry-deploy.md](docs/federation-registry-deploy.md),
[scripts/local_e2e/README.md](scripts/local_e2e/README.md),
[docs/peer-remote-test.md](docs/peer-remote-test.md).

---
Expand Down Expand Up @@ -95,11 +96,26 @@ SDS_ENV=production just federation-add-peer \
--gateway-api-base https://peer.example.edu/api/v1
```

Each gateway serves `GET https://<fqdn>/.well-known/sds-federation.json` (unsigned site identity).
During registry apply, set `FEDERATION_REGISTRY_CHALLENGE_TOKEN` on the applicant gateway so that
document includes `registry_challenge` for mothership verification.
Each site exposes `GET https://<fqdn>/.well-known/sds-federation.json` from **federation
sync** when Traefik routes that path to sync (recommended for production, sync-only peers,
and local lab with `compose.local.yaml`). Set the applicant challenge token on **sync**,
not the gateway django process.

Step-by-step (apply, env token, verify, local HTTPS caveats):
**Registry operator runbook:** [docs/federation-registry-deploy.md](docs/federation-registry-deploy.md)

**`FEDERATION_REGISTRY_CHALLENGE_TOKEN`** (applicant only — not mothership, not
`federation-shared.env`):

| Applicant deployment | Env file | After edit |
|---------------------|----------|------------|
| Local flagship / lab sync | `federation/.env.local` or env for `compose.local.yaml` | recreate `sds-federation-local-sync` |
| Sync-only peer (e.g. sds-fed1) | `federation/.env.peer` from `env.peer.example` | `compose.peer.*.yaml` recreate sync |
| Production site sync | `federation/site.env` | production compose recreate sync |

Use `cp federation/env.peer.example federation/.env.peer`; do **not** use `federation/peer.env`
(compose does not load it).

Verify UI and troubleshooting:
[`gateway/docs/federation-registry-verify.md`](../gateway/docs/federation-registry-verify.md).

Optional `--ca-cert-path` (file under `federation/certs/` in the sync container).
Expand Down Expand Up @@ -145,13 +161,27 @@ docker compose -f compose.local.yaml exec sds-gateway-local-app \

cd ../federation
cp federation.example.toml federation.toml # [site] matches gateway
# Flagship registry: cp signing key to secrets/registry/sign.pem (see secrets/registry/README.md)
just build && just up
curl -s http://localhost:8001/sync/health | jq .
```

Leave `FEDERATION_SYNC_SERVER_API_KEY` empty in `federation-shared.env` so sync mints
the export key. Optional: `FEDERATION_SKIP_SYNC_HEALTH_PROBE=true` until sync is up.

### Flagship registry (sync-owned manifest)

| Item | Location |
|------|----------|
| Signing key | `federation/secrets/registry/sign.pem` → container `/etc/sds/secrets/registry/sign.pem` |
| Published manifest | Docker volume `sds-federation-*-registry-publish` → `/var/lib/sds/registry-publish` |
| Public key + fingerprint | `federation/certs/sds-registry.pub.pem`; set `FEDERATION_REGISTRY_PUBKEY_FINGERPRINT` in `site.env` or `.env.local` |
| Gateway intake | Apply + **Verify domain** UI (→ sync internal API), staff approve, **Publish registry** |
| Sync internal API | `FEDERATION_SYNC_ADMIN_TOKEN` in `federation-shared.env`; gateway `FEDERATION_SYNC_INTERNAL_URL` |

Render/onboard with publish block: `FEDERATION_REGISTRY_PUBLISH_ENABLED=true` (see `site.example.env`).
Preflight: `just federation-doctor` or `FEDERATION_DOCTOR_CHECK=registry ./scripts/federation-doctor.sh`.

**Local peer mesh:**

```bash
Expand Down
14 changes: 14 additions & 0 deletions federation/compose.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,23 @@ services:
env_file:
- ../gateway/.envs/local/opensearch.env
- ../federation-shared.env
# Optional applicant / lab overrides (see env.local.example); gitignored when copied to .env.local
- path: ./.env.local
required: false
environment:
FEDERATION_CONFIG_PATH: /etc/sds/federation.toml
GATEWAY_INTERNAL_BASE_URL: http://sds-gateway-local-app:8000/api/v1
REDIS_URL: redis://sds-gateway-local-redis:6379/0
# Same interpolation pattern as compose.peer.* — values from shell, project .env, or compose --env-file
FEDERATION_REGISTRY_CHALLENGE_TOKEN: ${FEDERATION_REGISTRY_CHALLENGE_TOKEN:-}
FEDERATION_REGISTRY_WELL_KNOWN_URL: ${FEDERATION_REGISTRY_WELL_KNOWN_URL:-}
FEDERATION_REGISTRY_PUBKEY_FINGERPRINT: ${FEDERATION_REGISTRY_PUBKEY_FINGERPRINT:-}
volumes:
- ./federation.toml:/etc/sds/federation.toml:ro
- ./certs:/etc/sds/certs:ro
- ./secrets/registry:/etc/sds/secrets/registry:ro
- sds-federation-local-registry-publish:/var/lib/sds/registry-publish
- sds-federation-local-registry-cache:/var/lib/sds/registry
ports:
- "8001:8000"
healthcheck:
Expand All @@ -41,3 +51,7 @@ services:
networks:
- sds-network-local
- sds-gateway-local-opensearch-net

volumes:
sds-federation-local-registry-publish:
sds-federation-local-registry-cache:
2 changes: 2 additions & 0 deletions federation/compose.peer.local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ services:
OPENSEARCH_VERIFY_CERTS: "false"
# No mint: leave FEDERATION_SYNC_* unset
FEDERATION_SITE_NAME: peer
FEDERATION_REGISTRY_CHALLENGE_TOKEN: ${FEDERATION_REGISTRY_CHALLENGE_TOKEN:-}
volumes:
- ./federation.peer.toml:/etc/sds/federation.toml:ro
- ./certs:/etc/sds/certs:ro
ports:
- "8002:8000"
depends_on:
Expand Down
1 change: 1 addition & 0 deletions federation/compose.peer.remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ services:
OPENSEARCH_VERIFY_CERTS: "false"
FEDERATION_SITE_NAME: ${PEER_SITE_NAME:-fed1}
FEDERATION_BOOTSTRAP_ON_START: ${FEDERATION_BOOTSTRAP_ON_START:-true}
FEDERATION_REGISTRY_CHALLENGE_TOKEN: ${FEDERATION_REGISTRY_CHALLENGE_TOKEN:-}
volumes:
- ./federation.peer.toml:/etc/sds/federation.toml:ro
- ./certs:/etc/sds/certs:ro
Expand Down
9 changes: 8 additions & 1 deletion federation/compose.production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ services:
volumes:
- ./federation.toml:/etc/sds/federation.toml:ro
- ./certs:/etc/sds/certs:ro
- ./secrets/registry:/etc/sds/secrets/registry:ro
- sds-federation-prod-registry-publish:/var/lib/sds/registry-publish
- sds-federation-prod-registry-cache:/var/lib/sds/registry
ports:
- "8001:8000"
- "127.0.0.1:8001:8000"
healthcheck:
test:
[
Expand All @@ -40,3 +43,7 @@ services:
networks:
- sds-network-prod
- sds-gateway-prod-opensearch-net

volumes:
sds-federation-prod-registry-publish:
sds-federation-prod-registry-cache:
Loading
Loading