Rauthy som valg ved siden av Kanidm (innlogging på norsk) #4
No files matched your search
@@ -21,6 +21,7 @@ on:
|
||||
- gdo/**
|
||||
- nats/nats.conf
|
||||
- kanidm/server.toml.tpl
|
||||
- rauthy/config.toml
|
||||
- deploy-tomtervel
|
||||
- .gitea/workflows/deploy.yml
|
||||
workflow_dispatch:
|
||||
@@ -63,6 +64,17 @@ jobs:
|
||||
# location field is two numbers).
|
||||
MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }}
|
||||
MAPBOX_STYLE: ${{ vars.MAPBOX_STYLE }}
|
||||
# Optional: Rauthy beside or instead of Kanidm (README.md, "Rauthy").
|
||||
# RAUTHY_HOST and the three secrets run it (with `rauthy` in
|
||||
# COMPOSE_PROFILES); OIDC_ISSUER moves portal's and the chat's
|
||||
# sign-in to it; RAUTHY_API_KEY lets portal make accounts there.
|
||||
RAUTHY_HOST: ${{ vars.RAUTHY_HOST }}
|
||||
RAUTHY_ENC_KEY: ${{ secrets.RAUTHY_ENC_KEY }}
|
||||
RAUTHY_SECRET_RAFT: ${{ secrets.RAUTHY_SECRET_RAFT }}
|
||||
RAUTHY_SECRET_API: ${{ secrets.RAUTHY_SECRET_API }}
|
||||
OIDC_ISSUER: ${{ vars.OIDC_ISSUER }}
|
||||
RAUTHY_API_KEY: ${{ secrets.RAUTHY_API_KEY }}
|
||||
RAUTHY_LANGUAGE: ${{ vars.RAUTHY_LANGUAGE }}
|
||||
steps:
|
||||
# A missing value stops here, by name, before anything on the host
|
||||
# is touched. Only names are printed: the log is public.
|
||||
@@ -91,6 +103,8 @@ jobs:
|
||||
CNATS_TAG=$CNATS_TAG
|
||||
KRON_RELEASE=$KRON_RELEASE
|
||||
COMPOSE_PROFILES=$COMPOSE_PROFILES
|
||||
RAUTHY_HOST=$RAUTHY_HOST
|
||||
OIDC_ISSUER=$OIDC_ISSUER
|
||||
EOF
|
||||
cat > "$STAGE/portal.env" <<EOF
|
||||
NATS_URL=nats://portal:$NATS_PASSWORD@nats:4222
|
||||
@@ -115,6 +129,10 @@ jobs:
|
||||
GARAGE_UPLOADS_BUCKET=$GARAGE_UPLOADS_BUCKET
|
||||
MAPBOX_TOKEN=$MAPBOX_TOKEN
|
||||
MAPBOX_STYLE=$MAPBOX_STYLE
|
||||
OIDC_ISSUER=$OIDC_ISSUER
|
||||
RAUTHY_URL=${RAUTHY_HOST:+https://$RAUTHY_HOST}
|
||||
RAUTHY_API_KEY=$RAUTHY_API_KEY
|
||||
RAUTHY_LANGUAGE=$RAUTHY_LANGUAGE
|
||||
EOF
|
||||
# NATS itself (nats.conf reads NATS_PASSWORD), gdo and the chat.
|
||||
cat > "$STAGE/nats.env" <<EOF
|
||||
@@ -125,6 +143,22 @@ jobs:
|
||||
OAUTH2_CLIENT_ID=$CHAT_OAUTH2_CLIENT_ID
|
||||
OAUTH2_CLIENT_SECRET=$CHAT_OAUTH2_CLIENT_SECRET
|
||||
EOF
|
||||
# Rauthy's secrets, only where it runs. The first admin is the
|
||||
# vel's first person.
|
||||
if [ -n "$RAUTHY_ENC_KEY" ]; then
|
||||
for v in RAUTHY_HOST RAUTHY_SECRET_RAFT RAUTHY_SECRET_API; do
|
||||
[ -n "${!v}" ] || { echo "RAUTHY_ENC_KEY is set, but not $v"; exit 1; }
|
||||
done
|
||||
cat > "$STAGE/rauthy.env" <<EOF
|
||||
ENC_KEYS=$RAUTHY_ENC_KEY
|
||||
ENC_KEY_ACTIVE=${RAUTHY_ENC_KEY%%/*}
|
||||
HQL_SECRET_RAFT=$RAUTHY_SECRET_RAFT
|
||||
HQL_SECRET_API=$RAUTHY_SECRET_API
|
||||
BOOTSTRAP_ADMIN_EMAIL=$SEED_ADMIN_EMAIL
|
||||
RAUTHY_ADMIN_EMAIL=$SEED_ADMIN_EMAIL
|
||||
EVENT_EMAIL=$SEED_ADMIN_EMAIL
|
||||
EOF
|
||||
fi
|
||||
|
||||
- name: Pull and bring the stack up
|
||||
run: sudo /usr/local/bin/deploy-tomtervel
|
||||
@@ -8,3 +8,4 @@ gitea-oauth.secret
|
||||
dns/cloudflare.env
|
||||
nats.env
|
||||
kanidm-setup.secrets
|
||||
rauthy.env
|
||||
@@ -163,6 +163,10 @@ Run workflow**. Set them with `gt` (`gt variable set NAME --body ...`,
|
||||
| `MAPBOX_TOKEN` | secret | repo | optional: the map tiles portal proxies (the landing hero, location fields); unset, maps are off |
|
||||
| `MAPBOX_STYLE` | variable | repo | optional: `<owner>/<style>`; unset, `mapbox/streets-v12` |
|
||||
| `DNSCONTROL_VERSION` | variable | repo | the DNS workflow's dnscontrol |
|
||||
| `RAUTHY_HOST` | variable | repo | optional, Rauthy (see [Rauthy](#rauthy)): `konto.tomtervel.no` |
|
||||
| `RAUTHY_ENC_KEY`, `RAUTHY_SECRET_RAFT`, `RAUTHY_SECRET_API` | secret | repo | optional, Rauthy's own: made once, never changed (the key encrypts its database) |
|
||||
| `OIDC_ISSUER` | variable | repo | optional: `https://konto.tomtervel.no/auth/v1/` moves the site's and the chat's sign-in to Rauthy; unset, Kanidm |
|
||||
| `RAUTHY_API_KEY`, `RAUTHY_LANGUAGE` | secret, variable | repo | optional: portal makes accounts in Rauthy (`<name>$<secret>`, made in Rauthy's admin), in `nb` |
|
||||
|
||||
A variable is printed wherever a workflow echoes it, and this repo's run
|
||||
logs are public: a value that must not be read is a secret.
|
||||
@@ -172,6 +176,47 @@ and internal certificate (`bootstrap.sh`), and Garage's node secret.
|
||||
`kanidm/server.toml` takes `ID_HOST` once: Kanidm's domain is renamed on
|
||||
purpose, not by a variable changed (see dns/README.md).
|
||||
|
||||
## Rauthy
|
||||
|
||||
Kanidm has no Norwegian: its sign-in, its account pages and its mail
|
||||
are in English. [Rauthy](https://github.com/sebadob/rauthy) has
|
||||
Norwegian (`nb`) in all three, and portal (from the release after
|
||||
0.14.2) and the chat can sign in through it. It is here as a compose
|
||||
profile, off until it is asked for, so the vel can try it beside
|
||||
Kanidm and move when it is ready. Portal keeps the groups either way
|
||||
(`PEOPLE_BACKEND=memberships`), so moving takes no groups along.
|
||||
|
||||
Trying it, beside Kanidm:
|
||||
|
||||
1. The secrets, made once and never changed:
|
||||
```sh
|
||||
echo "$(openssl rand -hex 4)/$(openssl rand -base64 32)" | gt secret set RAUTHY_ENC_KEY -R tomtervel/infrastructure
|
||||
openssl rand -hex 24 | gt secret set RAUTHY_SECRET_RAFT -R tomtervel/infrastructure
|
||||
openssl rand -hex 24 | gt secret set RAUTHY_SECRET_API -R tomtervel/infrastructure
|
||||
gt variable set RAUTHY_HOST --body konto.tomtervel.no -R tomtervel/infrastructure
|
||||
gt variable set COMPOSE_PROFILES --body chat,rauthy -R tomtervel/infrastructure
|
||||
```
|
||||
2. DNS: `konto` is in `dns/dnsconfig.js`; run the dns workflow. Install
|
||||
`host-caddy/tomtervel.no` on kasse (it has the `konto` block) and
|
||||
reload Caddy. Reinstall `deploy-tomtervel` on kasse too: it now puts
|
||||
`rauthy.env` in place.
|
||||
3. Deploy. The first admin is `SEED_ADMIN_EMAIL`; its password is in the
|
||||
log once: `podman compose logs rauthy | grep -A2 -i password`.
|
||||
4. In Rauthy's admin (`https://konto.tomtervel.no/auth/v1/admin`): a
|
||||
client for the site (`authorization_code`, `S256`, scopes `openid
|
||||
profile email`, redirect `https://tomtervel.no/auth/callback`) and
|
||||
one for the chat (also `refresh_token`, redirect
|
||||
`https://chat.tomtervel.no/auth/callback`), and an API key with read
|
||||
and create on users.
|
||||
5. Moving the sign-in over is then values: `OIDC_ISSUER`,
|
||||
`OAUTH2_CLIENT_ID`/`OAUTH2_CLIENT_SECRET` and the chat's pair set to
|
||||
Rauthy's clients, `RAUTHY_API_KEY`, `RAUTHY_LANGUAGE=nb`, and a
|
||||
portal release that knows them. Back is the same values unset.
|
||||
|
||||
Rauthy's mail leaves through kasse's postfix like gdo's, and Rauthy
|
||||
stops if it cannot reach it. Its database is in the `rauthy_data`
|
||||
volume, which wants the same backups as NATS.
|
||||
|
||||
## Backups
|
||||
|
||||
- Kanidm writes a nightly backup into its volume (`/data/backups`,
|
||||
|
||||
+30
@@ -81,6 +81,32 @@ services:
|
||||
ports:
|
||||
- "127.0.0.1:8443:8443"
|
||||
|
||||
# Rauthy: sign-in, account pages and account mail in Norwegian, as an
|
||||
# alternative to Kanidm (which has no Norwegian). A profile, off unless
|
||||
# COMPOSE_PROFILES has `rauthy`; with it, portal and the chat sign in
|
||||
# here when OIDC_ISSUER is set, and portal makes accounts here with
|
||||
# RAUTHY_API_KEY. Its database is embedded (hiqlite), in rauthy_data.
|
||||
# Host-published for kasse's host Caddy (RAUTHY_HOST -> here).
|
||||
rauthy:
|
||||
profiles: ["rauthy"]
|
||||
image: ghcr.io/sebadob/rauthy:${RAUTHY_TAG:-0.37.2}
|
||||
restart: unless-stopped
|
||||
env_file:
|
||||
- path: rauthy.env
|
||||
required: false
|
||||
environment:
|
||||
PUB_URL: ${RAUTHY_HOST:-no-host-set}
|
||||
RP_ID: ${RAUTHY_HOST:-no-host-set}
|
||||
# Rauthy wants the port spelled out.
|
||||
RP_ORIGIN: https://${RAUTHY_HOST:-no-host-set}:443
|
||||
extra_hosts:
|
||||
- "host.containers.internal:host-gateway"
|
||||
volumes:
|
||||
- ./rauthy/config.toml:/app/config.toml:ro
|
||||
- rauthy_data:/app/data
|
||||
ports:
|
||||
- "127.0.0.1:8090:8080"
|
||||
|
||||
portal:
|
||||
build:
|
||||
context: ./portal
|
||||
@@ -163,6 +189,9 @@ services:
|
||||
# Must be the portal's own: a new name is a new, empty chat.
|
||||
SITE_NAME: tomtervel
|
||||
KANIDM_URL: https://${ID_HOST}
|
||||
# Set, the chat signs in through it instead of Kanidm (Rauthy:
|
||||
# https://<RAUTHY_HOST>/auth/v1/). Empty is unset.
|
||||
OIDC_ISSUER: ${OIDC_ISSUER:-}
|
||||
PUBLIC_URL: https://${CHAT_HOST}
|
||||
COOKIE_SECURE: "true"
|
||||
ports:
|
||||
@@ -189,6 +218,7 @@ volumes:
|
||||
caddy_config:
|
||||
nats_data:
|
||||
kanidm_data:
|
||||
rauthy_data:
|
||||
learn_cache:
|
||||
|
||||
# Pin the project network subnet inside 172.16/12 so Kanidm's X-Forwarded-For
|
||||
|
||||
@@ -18,6 +18,8 @@ set -euo pipefail
|
||||
root=/srv/tomtervel/infrastructure
|
||||
stage=/var/lib/gitea-runner/tomtervel-env
|
||||
files=(.env portal.env nats.env chat.env)
|
||||
# Written only when the site runs what needs it (Rauthy).
|
||||
optional=(rauthy.env)
|
||||
|
||||
[ -d "$root/.git" ] || { echo "no checkout at $root - bootstrap it first" >&2; exit 1; }
|
||||
for f in "${files[@]}"; do
|
||||
@@ -32,6 +34,11 @@ for f in "${files[@]}"; do
|
||||
install -m 0600 -o root -g root "$stage/$f" "$root/$f"
|
||||
rm -f "$stage/$f"
|
||||
done
|
||||
for f in "${optional[@]}"; do
|
||||
[ -s "$stage/$f" ] || continue
|
||||
install -m 0600 -o root -g root "$stage/$f" "$root/$f"
|
||||
rm -f "$stage/$f"
|
||||
done
|
||||
|
||||
# --build so a bumped PORTAL_RELEASE or GDO_RELEASE is actually fetched.
|
||||
podman compose up -d --build
|
||||
|
||||
@@ -32,6 +32,8 @@ D("tomtervel.no", REG_NONE, DnsProvider(DSP_CLOUDFLARE),
|
||||
CNAME("www", "tomtervel.no.", CF_PROXY_OFF),
|
||||
A("id", KASSE, CF_PROXY_OFF),
|
||||
A("chat", KASSE, CF_PROXY_OFF),
|
||||
// Rauthy, the Norwegian sign-in, beside Kanidm while the vel tries it.
|
||||
A("konto", KASSE, CF_PROXY_OFF),
|
||||
|
||||
// The old website, kept for now so the move can be undone: what the
|
||||
// apex and web. pointed at before (Netlify, through Cloudflare). The
|
||||
|
||||
@@ -40,3 +40,10 @@ id.tomtervel.no {
|
||||
chat.tomtervel.no {
|
||||
reverse_proxy 127.0.0.1:3070
|
||||
}
|
||||
|
||||
# Rauthy (compose profile `rauthy`): sign-in and account pages in
|
||||
# Norwegian, beside Kanidm until the vel moves over (README.md, "Rauthy").
|
||||
# Plain http on a loopback port; Caddy holds the certificate.
|
||||
konto.tomtervel.no {
|
||||
reverse_proxy 127.0.0.1:8090
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
# Rauthy, the vel's sign-in in Norwegian: what is not secret. The
|
||||
# secrets (the encryption key, the cluster secrets) and the names that
|
||||
# differ per site come from rauthy.env, which the deploy workflow writes
|
||||
# from the Actions secrets and variables (README.md). A profile: only
|
||||
# with `rauthy` in COMPOSE_PROFILES does it run.
|
||||
|
||||
[bootstrap]
|
||||
# The first admin's address, from BOOTSTRAP_ADMIN_EMAIL (rauthy.env).
|
||||
# Its password is printed once in the log on the very first start:
|
||||
# podman compose logs rauthy | grep -A2 -i password
|
||||
|
||||
[cluster]
|
||||
# One node, on its own.
|
||||
node_id = 1
|
||||
nodes = ["1 localhost:8100 localhost:8200"]
|
||||
|
||||
[email]
|
||||
# Through kasse's postfix, like gdo: the host signs the vel's mail
|
||||
# (DKIM for tomtervel.no) on the way out.
|
||||
smtp_url = "host.containers.internal"
|
||||
smtp_port = 25
|
||||
smtp_tls_mode = "danger-insecure"
|
||||
smtp_from = "Tomter Vel <post@tomtervel.no>"
|
||||
sub_prefix = "Tomter Vel"
|
||||
|
||||
[i18n]
|
||||
# Norwegian first, and English for whoever's browser asks for it.
|
||||
filter_lang_common = ["nb", "en"]
|
||||
filter_lang_admin = ["nb", "en"]
|
||||
|
||||
[server]
|
||||
# Behind kasse's host Caddy, which holds the certificate.
|
||||
scheme = "http"
|
||||
proxy_mode = true
|
||||
# Caddy reaches the published port from the host, which the container
|
||||
# sees as the project network's gateway (compose.yml pins 172.18/16).
|
||||
trusted_proxies = ["172.16.0.0/12"]
|
||||
Reference in new issue
Block a user