Some checks failed
ci / cargo test (abacus) (push) Has been cancelled
ci / cargo test (agent-runtime) (push) Has been cancelled
ci / cargo test (context-passport) (push) Has been cancelled
ci / cargo test (game-economy) (push) Has been cancelled
ci / cargo test (ledgerline) (push) Has been cancelled
ci / cargo test (mint) (push) Has been cancelled
ci / cargo test (rago) (push) Has been cancelled
ci / cargo test (relay) (push) Has been cancelled
ci / node suites (push) Has been cancelled
ci / cargo test (toolgate) (push) Has been cancelled
ci / cargo test (turnstile) (push) Has been cancelled
ci / cargo test (vend) (push) Has been cancelled
apps/gitea -> apps/rithub-server; compose services/containers renamed (rithub-server-app/postgres/act-runner) with explicit project name and volume names pinned to the exact existing Docker volumes (no data loss); our own GITEA_* compose/env var names -> RIT_*; new rit-admin CLI wrapper on railyard-box; giteaSession.mjs/giteaOAuth.mjs/giteaInfo.mjs -> ritSession/ritOAuth/ritInfo across 6 apps; GiteaForgeAdapter -> RitForgeAdapter + giteaSyncService/importGiteaRepos/syncGiteaRepos -> rit* in ritgram (tsc clean); apps/console/lib/gitea.ts -> lib/ritProvision.ts; Go internal/giteaclient -> internal/ritclient in rithub-async-import (go build/test clean); new /auth/rit + /forges/rit/connect routes with /gitea back-compat aliases; locale/swagger/footer/captcha template text scrubbed of remaining "Gitea" strings. Deployed to railyard-box: old containers stopped/removed, /srv/railyard-gitea renamed to /srv/rithub-server with a symlink kept, docker compose up -d from the new path, act_runner network-alias fix for its persisted instance URL. Live-verified: docker compose config diff showed zero unintended value changes, DB row counts unchanged (19 users, 635 repos), full route regression 200/expected, 0 "gitea" in headers/bodies on every checked page, real git clone+push over HTTPS and SSH with a disposable account (deleted after). Deferred on purpose (documented in plans/railyard.md): the forge discriminator / DB column names / Postgres role+volume names (data migrations, not a naming change) and the upstream GITEA__ env-to-ini keys and X-Gitea-* wire headers (hardcoded in the vendored engine binary). See plans/railyard.md RIT-OPS/RIT-BRD entry for the full old->new map and live evidence. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
88 lines
3.3 KiB
Bash
88 lines
3.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Adds Google / Apple sign-in to Rithub (rithub.dev).
|
|
#
|
|
# Runs ON railyard-box itself (no SSH hop), reading credentials from a
|
|
# single root-only file: /etc/products/rithub-oauth.env (same convention
|
|
# as /etc/products/scribase.env, /etc/products/toolgate.env). That file
|
|
# never exists in this repo — it is created on the box by the owner
|
|
# (see plans/railyard.md for the exact owner steps and callback URLs).
|
|
#
|
|
# Usage (on railyard-box):
|
|
# sudo bash /srv/rithub-server/scripts/add-rithub-oauth-sources.sh
|
|
#
|
|
# Each source is only added if its env vars are present in the env file;
|
|
# existing sources (by name) are left untouched so re-running is safe.
|
|
# This does not print any secret value, only which sources were
|
|
# added/skipped and why.
|
|
set -euo pipefail
|
|
|
|
ENV_FILE="/etc/products/rithub-oauth.env"
|
|
CONTAINER="rithub-server-app"
|
|
|
|
if [ ! -f "$ENV_FILE" ]; then
|
|
echo "no $ENV_FILE on this box yet -- nothing to do. See plans/railyard.md for the owner steps that create it." >&2
|
|
exit 0
|
|
fi
|
|
|
|
# shellcheck disable=SC1090
|
|
set -a
|
|
source "$ENV_FILE"
|
|
set +a
|
|
|
|
existing=$(docker exec -u git "$CONTAINER" gitea admin auth list 2>/dev/null || true)
|
|
|
|
add() { # name provider key secret [extra args...]
|
|
local name=$1 provider=$2 key=$3 secret=$4
|
|
shift 4
|
|
if [ -z "$key" ] || [ -z "$secret" ]; then
|
|
echo "skip $name: credentials not set in $ENV_FILE"
|
|
return
|
|
fi
|
|
if grep -q "[[:space:]]$name[[:space:]]" <<<"$existing"; then
|
|
echo "skip $name: already configured"
|
|
return
|
|
fi
|
|
docker exec -u git "$CONTAINER" gitea admin auth add-oauth \
|
|
--name "$name" --provider "$provider" --key "$key" --secret "$secret" "$@"
|
|
echo "added $name"
|
|
}
|
|
|
|
# GitHub sign-in removed for good (owner, 2026-11-30): Rithub auth = Google + email/password only.
|
|
|
|
add Google openidConnect "${RITHUB_GOOGLE_CLIENT_ID:-}" "${RITHUB_GOOGLE_CLIENT_SECRET:-}" \
|
|
--auto-discover-url https://accounts.google.com/.well-known/openid-configuration \
|
|
--scopes "openid email profile"
|
|
|
|
# Apple: Rithub needs a client *secret*, but Sign in with Apple issues a
|
|
# private signing key (.p8) instead -- the secret Rithub wants is a
|
|
# short-lived ES256 JWT you mint from that key. Max lifetime Apple allows
|
|
# is 6 months; re-running this script rotates it (skipped once a source
|
|
# named "Apple" already exists -- delete it first via `gitea admin auth (or rit-admin auth)
|
|
# delete --id <id>` to force a rotation).
|
|
APPLE_ID="${RITHUB_APPLE_SERVICES_ID:-}"
|
|
TEAM="${APPLE_TEAM_ID:-}"
|
|
KID="${RITHUB_APPLE_KEY_ID:-}"
|
|
P8="${RITHUB_APPLE_P8_PATH:-}"
|
|
if [ -n "$APPLE_ID" ] && [ -n "$TEAM" ] && [ -n "$KID" ] && [ -f "${P8:-/nonexistent}" ]; then
|
|
APPLE_SECRET=$(python3 - "$TEAM" "$KID" "$APPLE_ID" "$P8" <<'PY'
|
|
import sys, time, jwt
|
|
team, kid, sub, p8 = sys.argv[1:]
|
|
now = int(time.time())
|
|
print(jwt.encode(
|
|
{"iss": team, "iat": now, "exp": now + 180 * 86400, "aud": "https://appleid.apple.com", "sub": sub},
|
|
open(p8).read(),
|
|
algorithm="ES256",
|
|
headers={"kid": kid},
|
|
))
|
|
PY
|
|
)
|
|
add Apple openidConnect "$APPLE_ID" "$APPLE_SECRET" \
|
|
--auto-discover-url https://appleid.apple.com/.well-known/openid-configuration \
|
|
--scopes "openid"
|
|
else
|
|
echo "skip Apple: RITHUB_APPLE_SERVICES_ID / APPLE_TEAM_ID / RITHUB_APPLE_KEY_ID / RITHUB_APPLE_P8_PATH not all set in $ENV_FILE"
|
|
fi
|
|
|
|
echo "--- current oauth2 sources ---"
|
|
docker exec -u git "$CONTAINER" gitea admin auth list
|