feat(identity): register accounts and resend verification mail

This commit is contained in:
shira committed 2026-10-06 23:59:51 +03:00
1 parent 5e202ac972
commit 4436f626a3
55 files changed
+3227 -88

No files matched your search

+14 -10
View File
@@ -8,6 +8,10 @@ MONITORING_PROJECT ?= monitoring
APP_NETWORK ?= $(APP_PROJECT)_default
ENV_FILE ?= $(ROOT)/.env
CHECK_ENV_FILE := $(ROOT)/.env.example
# The example file has no usable IDENTITY_KEY_SECRET, which Compose requires.
# Commands that render or build from it get this value in their own
# environment only, never in .env targets, where it would override the real one.
CHECK_IDENTITY_KEY_SECRET := render-only-identity-key-secret-not-for-deployment
CORE_FILE := $(ROOT)/deploy/docker/docker-compose.yml
ML_FILE := $(ROOT)/deploy/docker/docker-compose.ml.yml
MONITORING_FILE := $(ROOT)/deploy/docker/docker-compose.monitoring.yml
@@ -36,15 +40,15 @@ config: ## Render all Compose files with safe example values
@test -f "$(ROOT)/backend/Dockerfile" || { printf 'Missing backend/Dockerfile.\n' >&2; exit 2; }
@test -f "$(ROOT)/frontend/Dockerfile" || { printf 'Missing frontend/Dockerfile.\n' >&2; exit 2; }
@test -f "$(ROOT)/ml/Dockerfile" || { printf 'Missing ml/Dockerfile.\n' >&2; exit 2; }
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(APP_PROJECT)" -f "$(CORE_FILE)" config --quiet
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(ML_PROJECT)" -f "$(ML_FILE)" config --quiet
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(MONITORING_PROJECT)" -f "$(MONITORING_FILE)" config --quiet
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" LINCODEX_RELEASE_TAG=000000000000 $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(APP_PROJECT)" -f "$(CORE_FILE)" -f "$(RELEASE_FILE)" config --quiet
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" LINCODEX_RELEASE_TAG=000000000000 $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(ML_PROJECT)" -f "$(ML_FILE)" -f "$(ML_RELEASE_FILE)" config --quiet
APP_PROJECT=lincodex-e2e-config APP_NETWORK=lincodex-e2e-config_default PLAYWRIGHT_VERSION="$(PLAYWRIGHT_VERSION)" E2E_UID=1000 E2E_GID=1000 E2E_SPEC_DIR="$(ROOT)/frontend/e2e" E2E_ARTIFACTS_DIR="$(ROOT)/frontend/test-results/e2e" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p lincodex-e2e-config -f "$(CORE_FILE)" -f "$(E2E_FILE)" --profile e2e config --quiet
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" IDENTITY_KEY_SECRET="$(CHECK_IDENTITY_KEY_SECRET)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(APP_PROJECT)" -f "$(CORE_FILE)" config --quiet
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" IDENTITY_KEY_SECRET="$(CHECK_IDENTITY_KEY_SECRET)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(ML_PROJECT)" -f "$(ML_FILE)" config --quiet
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" IDENTITY_KEY_SECRET="$(CHECK_IDENTITY_KEY_SECRET)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(MONITORING_PROJECT)" -f "$(MONITORING_FILE)" config --quiet
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" LINCODEX_RELEASE_TAG=000000000000 IDENTITY_KEY_SECRET="$(CHECK_IDENTITY_KEY_SECRET)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(APP_PROJECT)" -f "$(CORE_FILE)" -f "$(RELEASE_FILE)" config --quiet
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" LINCODEX_RELEASE_TAG=000000000000 IDENTITY_KEY_SECRET="$(CHECK_IDENTITY_KEY_SECRET)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(ML_PROJECT)" -f "$(ML_FILE)" -f "$(ML_RELEASE_FILE)" config --quiet
APP_PROJECT=lincodex-e2e-config APP_NETWORK=lincodex-e2e-config_default PLAYWRIGHT_VERSION="$(PLAYWRIGHT_VERSION)" E2E_UID=1000 E2E_GID=1000 E2E_SPEC_DIR="$(ROOT)/frontend/e2e" E2E_ARTIFACTS_DIR="$(ROOT)/frontend/test-results/e2e" IDENTITY_KEY_SECRET="$(CHECK_IDENTITY_KEY_SECRET)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p lincodex-e2e-config -f "$(CORE_FILE)" -f "$(E2E_FILE)" --profile e2e config --quiet
build: ## Build local frontend and backend images
APP_PROJECT="$(APP_PROJECT)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(APP_PROJECT)" -f "$(CORE_FILE)" build
APP_PROJECT="$(APP_PROJECT)" IDENTITY_KEY_SECRET="$(CHECK_IDENTITY_KEY_SECRET)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(APP_PROJECT)" -f "$(CORE_FILE)" build
up: ## Start the core app, PostgreSQL, Redis, SeaweedFS, and Kafka without monitoring
@test -f "$(ENV_FILE)" || { printf 'Missing %s. Copy .env.example to .env and replace the placeholder passwords.\n' "$(ENV_FILE)" >&2; exit 2; }
@@ -59,7 +63,7 @@ logs: ## Follow core service logs
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" $(DOCKER) compose --env-file "$(ENV_FILE)" -p "$(APP_PROJECT)" -f "$(CORE_FILE)" logs -f
monitoring-config: ## Render the separate monitoring Compose file
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(MONITORING_PROJECT)" -f "$(MONITORING_FILE)" config --quiet
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" IDENTITY_KEY_SECRET="$(CHECK_IDENTITY_KEY_SECRET)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(MONITORING_PROJECT)" -f "$(MONITORING_FILE)" config --quiet
monitoring-up: ## Start monitoring as a separate Compose project
@test -f "$(ENV_FILE)" || { printf 'Missing %s. Copy .env.example to .env and replace the placeholder passwords.\n' "$(ENV_FILE)" >&2; exit 2; }
@@ -74,10 +78,10 @@ monitoring-logs: ## Follow monitoring service logs
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" $(DOCKER) compose --env-file "$(ENV_FILE)" -p "$(MONITORING_PROJECT)" -f "$(MONITORING_FILE)" logs -f
ml-config: ## Render the separate ML Compose file
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(ML_PROJECT)" -f "$(ML_FILE)" config --quiet
APP_PROJECT="$(APP_PROJECT)" APP_NETWORK="$(APP_NETWORK)" IDENTITY_KEY_SECRET="$(CHECK_IDENTITY_KEY_SECRET)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(ML_PROJECT)" -f "$(ML_FILE)" config --quiet
ml-build: ## Build the ML image without starting it
APP_PROJECT="$(APP_PROJECT)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(ML_PROJECT)" -f "$(ML_FILE)" build
APP_PROJECT="$(APP_PROJECT)" IDENTITY_KEY_SECRET="$(CHECK_IDENTITY_KEY_SECRET)" $(DOCKER) compose --env-file "$(CHECK_ENV_FILE)" -p "$(ML_PROJECT)" -f "$(ML_FILE)" build
ml-up: ## Start the ML service as a separate Compose project
@test -f "$(ENV_FILE)" || { printf 'Missing %s. Copy .env.example to .env and replace the placeholder passwords.\n' "$(ENV_FILE)" >&2; exit 2; }
+6
View File
@@ -229,6 +229,12 @@ services:
SMTP_TLS_MODE: ${SMTP_TLS_MODE:-}
# Argon2id derivations that may run at once, 64 MiB each (1 to 4).
PASSWORD_HASH_CONCURRENCY: ${PASSWORD_HASH_CONCURRENCY:-1}
# Required: keys the registration idempotency records and rate limits.
# Generate with: openssl rand -base64 48
IDENTITY_KEY_SECRET: ${IDENTITY_KEY_SECRET:?set IDENTITY_KEY_SECRET in .env (openssl rand -base64 48)}
VERIFICATION_MAIL_MIN_INTERVAL: ${VERIFICATION_MAIL_MIN_INTERVAL:-1m}
VERIFICATION_MAIL_DAILY_LIMIT: ${VERIFICATION_MAIL_DAILY_LIMIT:-5}
IDENTITY_CLIENT_HOURLY_LIMIT: ${IDENTITY_CLIENT_HOURLY_LIMIT:-30}
# Proxies whose X-Forwarded-For is believed: only the frontend container,
# which has a fixed address on the pinned app network below. Other
# containers of that network (Prometheus, exporters, Alloy) are not
+1
View File
@@ -150,6 +150,7 @@ EMAIL_FROM=no-reply@example.com
EMAIL_TIMEOUT=10s
APP_PUBLIC_URL=http://localhost:8080
PASSWORD_HASH_CONCURRENCY=1
IDENTITY_KEY_SECRET=$(random_secret)
POSTGRES_EXPORTER_USER=
POSTGRES_EXPORTER_PASSWORD=
EOF
+15 -2
View File
@@ -50,6 +50,9 @@ EVIDENCE_SCHEMA = "lincodex.release-evidence/v1"
RELEASE_REGISTRY = "lincodex.invalid"
# Project name used only to render Compose files; nothing is started under it.
RENDER_PROJECT = "lincodex-release"
# Compose requires IDENTITY_KEY_SECRET and .env.example has none; this value only
# lets a render or build go through and is never deployed.
RENDER_ONLY_IDENTITY_KEY = "render-only-identity-key-secret-not-for-deployment"
CHECKS = ("smoke", "e2e")
CHECK_SCOPE = {
"smoke": (
@@ -538,7 +541,12 @@ class Docker:
args += ["-f", str(root / name)]
args += ["config", "--format", "json"]
env = docker_env(
{"APP_PROJECT": RENDER_PROJECT, "APP_NETWORK": f"{RENDER_PROJECT}_default", "LINCODEX_RELEASE_TAG": tag}
{
"APP_PROJECT": RENDER_PROJECT,
"APP_NETWORK": f"{RENDER_PROJECT}_default",
"LINCODEX_RELEASE_TAG": tag,
"IDENTITY_KEY_SECRET": RENDER_ONLY_IDENTITY_KEY,
}
)
return json.loads(run(args, cwd=root, env=env))
@@ -590,7 +598,12 @@ class Docker:
args += ["--build-arg", f"{name}={value}"]
args.append(service)
env = docker_env(
{"APP_PROJECT": RENDER_PROJECT, "APP_NETWORK": f"{RENDER_PROJECT}_default", "LINCODEX_RELEASE_TAG": tag}
{
"APP_PROJECT": RENDER_PROJECT,
"APP_NETWORK": f"{RENDER_PROJECT}_default",
"LINCODEX_RELEASE_TAG": tag,
"IDENTITY_KEY_SECRET": RENDER_ONLY_IDENTITY_KEY,
}
)
print(f"Building {service} for release {tag}", flush=True)
if subprocess.run(args, cwd=root, env=env, check=False).returncode != 0:
+3 -1
View File
@@ -26,13 +26,15 @@ port=18080
network="${project}_default"
storage_network="${project}_storage"
started=0
# .env.example has no usable IDENTITY_KEY_SECRET; the throwaway stack draws its own.
identity_key_secret=$(od -An -N24 -tx1 /dev/urandom | tr -d ' \n')
# The smoke stack sends no mail: it uses EMAIL_PROVIDER=disabled from
# .env.example and points mail links at its own loopback port.
compose() {
APP_PROJECT="$project" APP_NETWORK="$app_network" APP_STORAGE_NETWORK="$storage_network" APP_HTTP_PORT="$port" \
APP_SUBNET=172.29.81.0/24 APP_FRONTEND_IP=172.29.81.10 \
APP_PUBLIC_URL="http://localhost:$port" LINCODEX_RELEASE_TAG="$release_tag" docker compose \
APP_PUBLIC_URL="http://localhost:$port" LINCODEX_RELEASE_TAG="$release_tag" IDENTITY_KEY_SECRET="$identity_key_secret" docker compose \
--env-file "$env_file" \
-p "$project" \
"${compose_files[@]}" \
+4 -1
View File
@@ -63,7 +63,10 @@ def size_bytes(value):
def render_compose(file_names, project, extra_env=None, profiles=()):
if isinstance(file_names, str):
file_names = [file_names]
environment = dict(os.environ, APP_PROJECT=project, APP_NETWORK=f"{project}_default")
# The example file has no usable IDENTITY_KEY_SECRET, which Compose requires.
environment = dict(
os.environ, APP_PROJECT=project, APP_NETWORK=f"{project}_default", IDENTITY_KEY_SECRET="render-only-identity-key-secret"
)
for name in ("APP_HTTP_BIND", "APP_HTTP_PORT", "ML_BIND_ADDRESS", "APP_SUBNET", "APP_FRONTEND_IP", "TRUSTED_PROXY_CIDRS"):
environment.pop(name, None)
environment.update(extra_env or {})