44 Commits
Author SHA1 Message Date
blandClaude eab1f55cf7 gdo from the registry again: 0.4.0 is published
The stack built gdo from a commit while the gdo that dials a 1.0 site
was held back from the [uhhm] registry. It is there now, so the image
installs the package as before and the deploy no longer compiles gdo.
The build checks that the installed version is the one GDO_RELEASE
names.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDjTQg4CJsNqEo7hhE7
2026-11-24 19:13:04 +01:00
bl 3763271852 Merge pull request 'The stack for portal 1.0 (merging this is the switch)' (#19) from stack-1-0 into main
deploy / deploy (push) Successful in 13m51s
2026-11-24 18:30:59 +01:00
blandClaude 1f37681696 The stack for portal 1.0: a store of its own, gdo and kron dialling the site
Portal 1.0 keeps everything in one file (portal_data) and has no NATS.
gdo and kron dial it over dhd/1 from loopback, so the three share one
network namespace, held by a container of its own: held by portal, a
restart of portal cut the other two off. NATS stays behind a profile
nothing turns on, for going back; the chat (cnats) is out.

The deploy writes DHD_KEYS and the hash of LOAD_TOKEN, and no NATS or
chat settings. gdo is built from uhhm/gdo at GDO_RELEASE, since the gdo
that dials a site is not in the registry. move.sh reads the programs'
keys and prints what the deploy wants.

Run on kasse beside the live stack, on other ports, with made-up
records: mail out, a payment settled, content loaded over /dhd/1/load,
and both programs back after portal was restarted and made anew.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDjTQg4CJsNqEo7hhE7
2026-11-24 12:40:41 +01:00
blandClaude d1106dc1b8 move-1.0: the records from 0.19 into a 1.0 store, rehearsed
move.sh exports with 0.19.3, rewrites and imports with 1.0, takes the
sign-ups again through their form on a site only the host reaches, and
holds the store to the export. What that site would have mailed is posted
to sink.py and let go: left in the store, it goes out when gdo first dials.

README.md has the order of the switch and what it waits for: no gdo or
kron release dials a 1.0 site yet.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDjTQg4CJsNqEo7hhE7
2026-11-24 11:43:35 +01:00
bl 78e7aaba6d Merge pull request 'kron keeps an identity; the Vipps keys may be given on the desk' (#16) from kron-identity into main
deploy / deploy (push) Successful in 20s
2026-11-23 13:16:25 +01:00
bl 1c9004b30d Merge pull request 'DMARC reports go to dmarc@, not the board's inbox' (#17) from dmarc-alias into main
dns / dns (push) Successful in 5s
2026-11-23 13:15:44 +01:00
blandClaude Opus 5.5 43421f0923 dns: DMARC reports go to dmarc@, not the board's inbox
dns / dns (push) Successful in 4s
Each large mailbox provider mails post@ a daily XML report, and the
board forwards them on. dmarc@ is an address at Zoho, to be made there
before the zone is pushed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 17:06:53 +01:00
blandClaude Fable 5.1 6d5e936f18 kron keeps an identity, and the Vipps keys may be given on the desk
A volume for kron's age identity (KRON_IDENTITY_FILE), KRON_LANG, and
kron.env written with only the VIPPS_* the deploy holds: none, and kron
asks for them through portal, sealed to that identity.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-11 22:41:19 +01:00
bl 48f286650b Merge pull request 'deploy-tomtervel: kron.env is one of the optional env files' (#14) from deploy-kron-env into main
deploy / deploy (push) Failing after 2s
Reviewed-on: #14
2026-11-10 22:31:01 +01:00
blandClaude Fable 5.1 99852cdce6 deploy-tomtervel: kron.env is one of the optional env files
The first deploy with the pay profile failed: compose wanted kron.env
in the checkout and the host script only moves the files it knows.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-10 22:27:40 +01:00
bl 3d7da36401 Merge pull request 'deploy: check out the repo, so its scripts are there' (#12) from deploy-checkout into main
deploy / deploy (push) Successful in 11s
Reviewed-on: #12
2026-11-10 22:07:49 +01:00
bl bd37ae5786 Merge pull request 'kron in the stack, auto_link for Vipps Login, and the vel's colours in Rauthy' (#13) from kron-pay into main
deploy / deploy (push) Failing after 1m39s
dns / dns (push) Successful in 4s
Reviewed-on: #13
2026-11-10 22:07:40 +01:00
bl 6cbd6ada9b Merge branch 'main' into kron-pay 2026-11-10 22:05:04 +01:00
blandClaude Fable 5.1 459f780049 deploy: check out the repo, so its scripts are there
The deploy of #10 failed at the Rauthy providers step with
"./rauthy-providers.sh: No such file or directory": the job wrote env
files and ran the host script, but never had the repo itself.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-10 22:05:03 +01:00
blandClaude Fable 5.1 0c60e8f181 kron's image from project.uhhm.no, where its release publishes it
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-10 20:37:32 +01:00
blandClaude Fable 5.1 7e241a90d0 Tomter Vel's colours on Rauthy's pages, kept by the deploy
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-10 20:27:49 +01:00
blandClaude Fable 5.1 a0af480890 kron in the stack: the money service, Vipps ePayment for Medlemskap
Under the pay profile: kron.env from the Medlemskap sales unit's keys,
PAY_URL for portal once the profile is on, betaling.tomtervel.no in DNS
and kasse's Caddy, and vipps-webhook.sh for the one-time webhook
registration whose secret must never reach a public log.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-10 20:25:46 +01:00
blandClaude Fable 5.1 47342b0867 Vipps Login: auto_link, so Vipps and a password lead to the same account
A board member with a password account who presses Vipps was refused
and told to link it from the account page. Vipps verifies the email,
which is the same address the invite trusted, so the link is made on
the spot instead.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-10 20:24:27 +01:00
bl 97083982ba Merge pull request 'Vipps Login as a sign-in provider in Rauthy, kept by the deploy' (#10) from rauthy-vipps-login into main
deploy / deploy (push) Failing after 6s
Reviewed-on: #10
2026-11-10 18:45:28 +01:00
blandClaude Fable 5.1 c88d396ad7 README: the Vipps Login values, and auth providers on the API key
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-10 18:08:36 +01:00
blandClaude Fable 5.1 33e102dc25 Vipps Login as a sign-in provider in Rauthy, kept by the deploy
Rauthy has no file for its upstream providers, only its API, so
rauthy-providers.sh is the file: every deploy makes Vipps the first time
and updates it after, by name, from VIPPS_LOGIN_CLIENT_ID and
VIPPS_LOGIN_CLIENT_SECRET (the login sales unit's keys). Scopes openid
name email phoneNumber, PKCE, an account made on the first sign-in. The
redirect URI https://konto.tomtervel.no/auth/v1/providers/callback must
be registered on the sales unit in the Vipps portal. The portal API key
needs AuthProviders read, create and update for this.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-11-10 18:07:13 +01:00
blandClaude Opus 5.5 64fc9a1911 README: portal's Rauthy client needs the groups scope, or a sign-in carries no groups
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 14:39:43 +01:00
blandClaude Opus 5.5 b2ee900602 README: the groups are in Rauthy (PEOPLE_BACKEND=rauthy), as the variable says
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 12:21:27 +01:00
blandClaude Opus 5.5 b128801ee2 deploy: a "$" in a secret reaches the container whole
deploy / deploy (push) Successful in 20s
Compose reads an env_file the way it reads compose.yml: "$name" in a value
is a variable to fill in, and one that is not set comes out empty.
Rauthy's API keys are "<name>$<secret>", so RAUTHY_API_KEY reached portal
as "portal" alone: Rauthy answered 401 to every call, and every invite
failed with "the account could not be made just now". The env files'
values are the secrets themselves, so every "$" left in them is literal
and becomes compose's "$$". Checked with compose 5.7.0 (kasse's): the
container gets "portal$Abc123secret" from "portal$$Abc123secret".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:57:26 +01:00
blandClaude Opus 5.5 fdac5084d1 README: portal's Rauthy key needs roles too, and a dead key answers 401
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 11:39:07 +01:00
blandClaude Opus 5.5 4cf56ac588 Images upgrade the whole base, not part of it (pacman -Syu)
deploy / deploy (push) Successful in 1m38s
pacman -Sy then installing curl or gdo is a partial upgrade: with openssl
4.1.0 in the repos (November 2026) it pulls the new libssl while the base
image's own pacman, libarchive and cryptsetup still want libcrypto.so=3,
and refuses. The portal 0.18.2 deploy failed on it. -Syu moves the whole
image to what the repos have, which the builder is too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 10:41:32 +01:00
blandClaude Opus 5.5 69489e7e42 Previews: one name per branch under forhandsvisning.tomtervel.no
dns / dns (push) Successful in 6s
The content repo now runs one preview per branch, for five days after its
last push, behind its own router on 127.0.0.1:3066
(tomtervel/questions, .gitea/preview/). This is kasse's side of it:

- dns: *.forhandsvisning beside the bare name, both unproxied to kasse.
- host-caddy: the bare name and *.forhandsvisning go to 3066 instead of
  the single preview on 3065. A branch's name gets its certificate on
  demand, and only after the router says the branch has a preview, so
  made-up names cannot use up Let's Encrypt's limits. That needs the
  on_demand_tls ask option in kasse's global Caddyfile, described in the
  file. Also brings the file back in line with what kasse runs.
- README: the Previews section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 08:58:30 +01:00
bl 100002baa2 Merge pull request 'Forhåndsvisningen på port 3065 (3060 er gullberg sin)' (#9) from forhandsvisning-port into main
Reviewed-on: #9
2026-11-08 16:10:40 +01:00
blandClaude Opus 5.5 1943482d74 Forhåndsvisningen på 3065: 3060 er gullberg sin
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-08 16:09:09 +01:00
bl dc29f02caa Merge pull request 'Forhåndsvisning av innholdsgrener: forhandsvisning.tomtervel.no' (#8) from forhandsvisning into main
dns / dns (push) Successful in 5s
deploy / deploy (push) Successful in 21s
Reviewed-on: #8
2026-11-08 15:55:15 +01:00
blandClaude Opus 5.5 07c632c1ee Forhåndsvisning: navn på portalbildet, DNS og Caddy for forhandsvisning.tomtervel.no
dns / dns (push) Successful in 5s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-08 15:52:45 +01:00
bl 19873965cd Merge pull request 'Uten Kanidm: Rauthy er innloggingen' (#7) from uten-kanidm into main
dns / dns (push) Successful in 5s
deploy / deploy (push) Successful in 22s
Reviewed-on: #7
2026-11-08 13:33:55 +01:00
blandClaude Opus 5.5 ee0ab982a1 Uten Kanidm: Rauthy er innloggingen
dns / dns (push) Successful in 4s
Kanidm ut av stacken, bootstrap.sh, kanidm-setup.sh og kanidm/ borte.
Rauthy er en vanlig tjeneste, ikke en profil, og deployen krever dens
verdier i stedet for ID_HOST og KANIDM_API_TOKEN. Portalen får ingen
KANIDM_* lenger, så kontoene lages i Rauthy. id.tomtervel.no sender
videre til konto. Volumet kanidm_data blir liggende på kasse urørt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-08 13:32:28 +01:00
bl 7620cd15fb Merge pull request 'Samtalene på samtaler.tomtervel.no' (#6) from samtaler into main
dns / dns (push) Successful in 5s
Reviewed-on: #6
2026-11-08 13:23:45 +01:00
blandClaude Opus 5.5 5f69b217e9 Samtalene på samtaler.tomtervel.no, chat. sender videre
dns / dns (push) Successful in 5s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-08 13:21:27 +01:00
bl 94eade5707 Merge pull request 'Rauthy: en kortlivet nøkkel ved første start, til klientene' (#5) from rauthy-provision into main
deploy / deploy (push) Successful in 38s
Reviewed-on: #5
2026-11-08 12:31:52 +01:00
blandClaude Opus 5.5 1ef375a21c Write the bootstrap key only when it is set
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-08 12:07:53 +01:00
blandClaude Opus 5.5 9e986bfde4 Rauthy's first start may bootstrap a short-lived key for the clients
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-08 12:07:30 +01:00
bl 572e6dc2ea Merge pull request 'Rauthy som valg ved siden av Kanidm (innlogging på norsk)' (#4) from rauthy into main
deploy / deploy (push) Successful in 22s
dns / dns (push) Successful in 5s
2026-11-08 11:59:10 +01:00
blandClaude Opus 5.5 961d090b7d Rauthy as a compose profile: sign-in in Norwegian, off until asked for
dns / dns (push) Successful in 4s
A rauthy service under the profile of the same name, its config here
without secrets, and rauthy.env written by the deploy from Actions
secrets. OIDC_ISSUER moves portal's and the chat's sign-in to it,
RAUTHY_API_KEY lets portal make accounts there. konto.tomtervel.no in
DNS and kasse's Caddy, beside id. Nothing runs until RAUTHY_HOST, the
three secrets and the profile are set.

Tried locally: the config starts, the issuer is https://<host>/auth/v1/,
and a Norwegian browser gets the pages in nb.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-07 22:33:46 +01:00
bl 5524b1be01 Merge pull request 'Kart: MAPBOX_TOKEN og MAPBOX_STYLE, og kasses Caddy for tomtervel.no' (#3) from mapbox into main
deploy / deploy (push) Successful in 24s
Reviewed-on: #3
2026-11-07 18:04:36 +01:00
blandClaude Opus 5.5 3dc0aa4869 kasse's Caddy for tomtervel.no, www, id and chat
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-07 17:50:49 +01:00
blandClaude Opus 5.5 1ea4ad7b03 Maps: MAPBOX_TOKEN (secret) and MAPBOX_STYLE (variable), both optional
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-07 17:50:33 +01:00
bl 371f84a9e5 Merge pull request 'Den gamle nettsiden på gammel.tomtervel.no, og PORTAL_RELEASE i org-en' (#2) from gammel into main
dns / dns (push) Successful in 5s
Reviewed-on: #2
2026-11-07 16:58:19 +01:00
22 changed files with 1269 additions and 600 deletions

No files matched your search

+134 -31
View File
@@ -2,7 +2,8 @@
# Actions variable (vars.*: hosts, versions, where the content comes from)
# or secret (secrets.*: passwords, tokens, the first person's address) of
# this repo, or of the tomtervel org for what other repos share
# (NATS_PASSWORD, which the content repo's reload uses too). The table is
# (LOAD_TOKEN, which the content repo's reload posts to the site, and
# PORTAL_RELEASE, which its lint runs). The table is
# in README.md. A new host name or a portal bump is a variable changed and
# then Run workflow; a change to the files here deploys on push.
#
@@ -19,8 +20,9 @@ on:
- Caddyfile
- portal/**
- gdo/**
- nats/nats.conf
- kanidm/server.toml.tpl
- rauthy-providers.sh
- rauthy-theme.sh
- rauthy/config.toml
- deploy-tomtervel
- .gitea/workflows/deploy.yml
workflow_dispatch:
@@ -33,11 +35,9 @@ jobs:
STAGE: /var/lib/gitea-runner/tomtervel-env
# What the stack is.
PORTAL_HOST: ${{ vars.PORTAL_HOST }}
ID_HOST: ${{ vars.ID_HOST }}
CHAT_HOST: ${{ vars.CHAT_HOST }}
PAY_HOST: ${{ vars.PAY_HOST }}
PORTAL_RELEASE: ${{ vars.PORTAL_RELEASE }}
GDO_RELEASE: ${{ vars.GDO_RELEASE }}
CNATS_TAG: ${{ vars.CNATS_TAG }}
KRON_RELEASE: ${{ vars.KRON_RELEASE }}
COMPOSE_PROFILES: ${{ vars.COMPOSE_PROFILES }}
CONTENT_REPO: ${{ vars.CONTENT_REPO }}
@@ -46,56 +46,108 @@ jobs:
PEOPLE_BACKEND: ${{ vars.PEOPLE_BACKEND }}
RESPONSIBLE_GROUP: ${{ vars.RESPONSIBLE_GROUP }}
OAUTH2_CLIENT_ID: ${{ vars.OAUTH2_CLIENT_ID }}
CHAT_OAUTH2_CLIENT_ID: ${{ vars.CHAT_OAUTH2_CLIENT_ID }}
NATS_ADOPT_LEGACY: ${{ vars.NATS_ADOPT_LEGACY }}
GARAGE_S3_ENDPOINT: ${{ vars.GARAGE_S3_ENDPOINT }}
GARAGE_UPLOADS_BUCKET: ${{ vars.GARAGE_UPLOADS_BUCKET }}
# The programs beside the site (README.md, "The site's own
# network"): each one's key and what it may do, and the site's own
# key and where it listens. Public keys, said in the logs; set
# once, from what move-1.0/move.sh prints.
DHD_KEYS: ${{ vars.DHD_KEYS }}
PORTAL_DHD: ${{ vars.PORTAL_DHD }}
# Optional: sealed copies of the site's store, every six hours
# (README.md, "Backups"). PORTAL_BACKUP_TO is an age public key
# whose private half is kept off this host.
PORTAL_BACKUP_TO: ${{ vars.PORTAL_BACKUP_TO }}
GARAGE_BACKUPS_BUCKET: ${{ vars.GARAGE_BACKUPS_BUCKET }}
# What it runs with.
NATS_PASSWORD: ${{ secrets.NATS_PASSWORD }}
# The token the content repo's reload posts; the site is given
# its hash alone.
LOAD_TOKEN: ${{ secrets.LOAD_TOKEN }}
OAUTH2_CLIENT_SECRET: ${{ secrets.OAUTH2_CLIENT_SECRET }}
CHAT_OAUTH2_CLIENT_SECRET: ${{ secrets.CHAT_OAUTH2_CLIENT_SECRET }}
KANIDM_API_TOKEN: ${{ secrets.KANIDM_API_TOKEN }}
GARAGE_ACCESS_KEY: ${{ secrets.GARAGE_ACCESS_KEY }}
GARAGE_SECRET_KEY: ${{ secrets.GARAGE_SECRET_KEY }}
SEED_ADMIN_EMAIL: ${{ secrets.SEED_ADMIN_EMAIL }}
SEED_ADMIN_NAME: ${{ secrets.SEED_ADMIN_NAME }}
# Optional: unset, maps are off (the landing hero is empty, a
# location field is two numbers).
MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }}
MAPBOX_STYLE: ${{ vars.MAPBOX_STYLE }}
# Who is who: Rauthy (README.md, "Rauthy"). RAUTHY_HOST and the
# three secrets run it; portal signs in at OIDC_ISSUER;
# 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 }}
# Optional, for Rauthy's very first start only: a short-lived key
# (base64 JSON, README.md "Rauthy") that makes the clients. Rauthy
# reads it into an empty database and never again.
RAUTHY_BOOTSTRAP_API_KEY: ${{ secrets.RAUTHY_BOOTSTRAP_API_KEY }}
RAUTHY_BOOTSTRAP_API_KEY_SECRET: ${{ secrets.RAUTHY_BOOTSTRAP_API_KEY_SECRET }}
OIDC_ISSUER: ${{ vars.OIDC_ISSUER }}
RAUTHY_API_KEY: ${{ secrets.RAUTHY_API_KEY }}
RAUTHY_LANGUAGE: ${{ vars.RAUTHY_LANGUAGE }}
# The money service (README.md, "Payments"): Vipps's keys for the
# Medlemskap sales unit, read by kron alone, from its env: with
# all four set kron asks the site for nothing. VIPPS_WEBHOOK_SECRET may wait, kron
# then settles by asking Vipps every minute instead.
VIPPS_MSN: ${{ vars.VIPPS_MSN }}
VIPPS_CLIENT_ID: ${{ secrets.VIPPS_CLIENT_ID }}
VIPPS_CLIENT_SECRET: ${{ secrets.VIPPS_CLIENT_SECRET }}
VIPPS_SUBSCRIPTION_KEY: ${{ secrets.VIPPS_SUBSCRIPTION_KEY }}
VIPPS_WEBHOOK_SECRET: ${{ secrets.VIPPS_WEBHOOK_SECRET }}
steps:
# The repo's own scripts (rauthy-providers.sh) run from the
# checkout; the stack itself is pulled on the host by
# deploy-tomtervel, not from here.
- uses: actions/checkout@v4
# A missing value stops here, by name, before anything on the host
# is touched. Only names are printed: the log is public.
- name: Write the env files
run: |
missing=
for v in PORTAL_HOST ID_HOST CHAT_HOST PORTAL_RELEASE GDO_RELEASE CNATS_TAG \
for v in PORTAL_HOST RAUTHY_HOST OIDC_ISSUER PORTAL_RELEASE GDO_RELEASE \
KRON_RELEASE CONTENT_REPO CONTENT_BRANCH SITE_NAME PEOPLE_BACKEND \
RESPONSIBLE_GROUP OAUTH2_CLIENT_ID CHAT_OAUTH2_CLIENT_ID \
RESPONSIBLE_GROUP OAUTH2_CLIENT_ID \
GARAGE_S3_ENDPOINT GARAGE_UPLOADS_BUCKET \
NATS_PASSWORD OAUTH2_CLIENT_SECRET CHAT_OAUTH2_CLIENT_SECRET \
KANIDM_API_TOKEN GARAGE_ACCESS_KEY GARAGE_SECRET_KEY SEED_ADMIN_EMAIL; do
DHD_KEYS PORTAL_DHD LOAD_TOKEN OAUTH2_CLIENT_SECRET \
RAUTHY_ENC_KEY RAUTHY_SECRET_RAFT RAUTHY_SECRET_API RAUTHY_API_KEY \
GARAGE_ACCESS_KEY GARAGE_SECRET_KEY SEED_ADMIN_EMAIL; do
[ -n "${!v}" ] || missing="$missing $v"
done
[ -z "$missing" ] || { echo "not set as an Actions variable or secret:$missing"; exit 1; }
pay=
case ",$COMPOSE_PROFILES," in *,pay,*) pay=1;; esac
if [ -n "$pay" ]; then
for v in PAY_HOST VIPPS_MSN VIPPS_CLIENT_ID VIPPS_CLIENT_SECRET VIPPS_SUBSCRIPTION_KEY; do
[ -n "${!v}" ] || missing="$missing $v"
done
[ -z "$missing" ] || { echo "COMPOSE_PROFILES has pay, but not set:$missing"; exit 1; }
fi
umask 077
mkdir -p "$STAGE"
# Interpolated by compose: hosts, versions, profiles. No secret.
cat > "$STAGE/.env" <<EOF
PORTAL_HOST=$PORTAL_HOST
ID_HOST=$ID_HOST
CHAT_HOST=$CHAT_HOST
PORTAL_RELEASE=$PORTAL_RELEASE
GDO_RELEASE=$GDO_RELEASE
CNATS_TAG=$CNATS_TAG
KRON_RELEASE=$KRON_RELEASE
PORTAL_DHD=$PORTAL_DHD
COMPOSE_PROFILES=$COMPOSE_PROFILES
PAY_HOST=$PAY_HOST
RAUTHY_HOST=$RAUTHY_HOST
OIDC_ISSUER=$OIDC_ISSUER
EOF
# The site keeps no token, only its hash.
load_hash=$(printf %s "$LOAD_TOKEN" | sha256sum | cut -d' ' -f1)
cat > "$STAGE/portal.env" <<EOF
NATS_URL=nats://portal:$NATS_PASSWORD@nats:4222
PUBLIC_URL=https://$PORTAL_HOST
KANIDM_URL=https://$ID_HOST
CHAT_URL=https://$CHAT_HOST
DHD_KEYS=$DHD_KEYS
DHD_TOKENS=$load_hash=load
OAUTH2_CLIENT_ID=$OAUTH2_CLIENT_ID
OAUTH2_CLIENT_SECRET=$OAUTH2_CLIENT_SECRET
KANIDM_API_TOKEN=$KANIDM_API_TOKEN
COOKIE_SECURE=true
CONTENT_REPO=$CONTENT_REPO
CONTENT_BRANCH=$CONTENT_BRANCH
@@ -104,21 +156,72 @@ jobs:
RESPONSIBLE_GROUP=$RESPONSIBLE_GROUP
SEED_ADMIN_EMAIL=$SEED_ADMIN_EMAIL
SEED_ADMIN_NAME=$SEED_ADMIN_NAME
NATS_ADOPT_LEGACY=$NATS_ADOPT_LEGACY
GARAGE_S3_ENDPOINT=$GARAGE_S3_ENDPOINT
GARAGE_ACCESS_KEY=$GARAGE_ACCESS_KEY
GARAGE_SECRET_KEY=$GARAGE_SECRET_KEY
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
NATS_PASSWORD=$NATS_PASSWORD
NATS_URL=nats://portal:$NATS_PASSWORD@nats:4222
EOF
cat > "$STAGE/chat.env" <<EOF
OAUTH2_CLIENT_ID=$CHAT_OAUTH2_CLIENT_ID
OAUTH2_CLIENT_SECRET=$CHAT_OAUTH2_CLIENT_SECRET
# With the money service in the stack, portal may ask for
# payments without `by_hand`; the address itself is never
# called (kron dials the site), the lint only reads that it is
# set. The content repo's lint sets it the same way.
if [ -n "$pay" ]; then
echo "PAY_URL=http://127.0.0.1:3080" >> "$STAGE/portal.env"
fi
if [ -n "$PORTAL_BACKUP_TO" ] && [ -n "$GARAGE_BACKUPS_BUCKET" ]; then
printf 'PORTAL_BACKUP_TO=%s\nGARAGE_BACKUPS_BUCKET=%s\n' "$PORTAL_BACKUP_TO" "$GARAGE_BACKUPS_BUCKET" >> "$STAGE/portal.env"
fi
# kron: Vipps's keys for the Medlemskap sales unit (kron refuses
# some set and some not). Written even without the profile, so
# the file compose names is there.
{
echo "WEBHOOK_SECRET=$VIPPS_WEBHOOK_SECRET"
for name in VIPPS_MSN VIPPS_CLIENT_ID VIPPS_CLIENT_SECRET VIPPS_SUBSCRIPTION_KEY; do
if [ -n "${!name}" ]; then echo "$name=${!name}"; fi
done
} > "$STAGE/kron.env"
# Rauthy's secrets. The first admin is the vel's first person.
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
if [ -n "$RAUTHY_BOOTSTRAP_API_KEY" ]; then
printf 'BOOTSTRAP_API_KEY=%s\nBOOTSTRAP_API_KEY_SECRET=%s\n' \
"$RAUTHY_BOOTSTRAP_API_KEY" "$RAUTHY_BOOTSTRAP_API_KEY_SECRET" >> "$STAGE/rauthy.env"
fi
# Compose reads an env_file the way it reads compose.yml: "$name" in
# a value is a variable to fill in, and one that is not set comes
# out empty. Every value above is the secret itself, so a "$" left
# in one is literal (Rauthy's API keys are "<name>$<secret>"), and
# "$$" is compose's literal "$". Without this, RAUTHY_API_KEY reached
# portal as "portal" alone, Rauthy answered 401, and every invite
# failed. .env is left alone: it is what compose.yml interpolates.
sed -i 's/\$/$$/g' "$STAGE/portal.env" "$STAGE/rauthy.env" "$STAGE/kron.env"
- name: Pull and bring the stack up
run: sudo /usr/local/bin/deploy-tomtervel
# The sign-in providers Rauthy offers (Vipps Login), kept by the
# deploy through Rauthy's API: rauthy-providers.sh. Unset values
# change nothing.
- name: Sign-in providers in Rauthy
env:
VIPPS_LOGIN_CLIENT_ID: ${{ vars.VIPPS_LOGIN_CLIENT_ID }}
VIPPS_LOGIN_CLIENT_SECRET: ${{ secrets.VIPPS_LOGIN_CLIENT_SECRET }}
run: ./rauthy-providers.sh
# The vel's colours on Rauthy's pages: rauthy-theme.sh. Needs the
# API key to have Clients read and update; without, it says so.
- name: Colours in Rauthy
run: ./rauthy-theme.sh
+2 -4
View File
@@ -1,10 +1,8 @@
.env
portal.env
chat.env
kanidm/server.toml
certs/
.kanidm-recovered
gitea-oauth.secret
dns/cloudflare.env
nats.env
kanidm-setup.secrets
rauthy.env
kron.env
+4 -10
View File
@@ -1,17 +1,11 @@
# Public TLS for both hosts, real certificates from Let's Encrypt over
# HTTP-01: the DNS A records for ${PORTAL_HOST} and ${ID_HOST} must
# HTTP-01: the DNS A records for ${PORTAL_HOST} and ${RAUTHY_HOST} must
# point at this host before the first start.
{$ID_HOST} {
# Kanidm serves its own (internal, self-signed) TLS; verification is
# skipped on the inside hop only.
reverse_proxy kanidm:8443 {
transport http {
tls_insecure_skip_verify
}
}
{$RAUTHY_HOST} {
reverse_proxy rauthy:8080
log {
output file /data/id.log
output file /data/konto.log
}
}
+245 -162
View File
@@ -1,130 +1,112 @@
# Tomter Vel — infrastructure
Everything the vel's own site needs on one host, as containers: Caddy
for TLS, NATS with JetStream for the records, Kanidm for who is who,
and portal, the site itself. The content (pages, forms, desks) lives
in [tomtervel/questions](https://prosjekt.klingenbergbygg.no/tomtervel/questions)
Everything the vel's own site needs on one host, as containers: portal,
the site itself, which keeps its records in one file of its own; Rauthy
for who is who; gdo for its mail and kron for Vipps. The content (pages,
forms, desks) lives in
[tomtervel/questions](https://prosjekt.klingenbergbygg.no/tomtervel/questions)
and is fetched from there; this repo owns the host.
```
Internet ──► Caddy (Let's Encrypt)
├── PORTAL_HOST ──► portal:3000 ──► NATS (records) + Kanidm (login)
└── ID_HOST ─────► kanidm:8443 (internal TLS)
├── PORTAL_HOST ──► portal:3000 ──► its store (portal_data) + Rauthy (login)
├── RAUTHY_HOST ──► rauthy:8080 ▲ dhd/1, on loopback
└── PAY_HOST ─────► kron:3080 ───────────┤
gdo ─────────────────┘──► the host's mail server
```
Today the vel's draft site runs on Klingenberg Bygg's host as
vel.klingenbergbygg.no, sharing that host's Kanidm and NATS. This repo
is the same site on a host of the vel's own, with a Kanidm of its own,
so nothing about the vel's members or records depends on anyone else.
Nothing about the vel's members or records depends on anyone else's
host: the login and the site are the vel's own.
The site ran portal 0.19 on NATS until the move to 1.0, which
`move-1.0/` is. The chat (cnats) spoke to portal over NATS and went
with it; the one that dials a 1.0 site (uhhm/kino) has no image yet.
## First start
On a fresh Linux host with podman + podman-compose and openssl (run rootful,
i.e. as root, so Caddy can bind 80/443 and Kanidm sees a stable source IP),
with a Gitea runner on it, and the variables and secrets below set
(`NATS_PASSWORD` is any long random string: `openssl rand -hex 24`):
On a fresh Linux host with podman + podman-compose (run rootful, so Caddy
can bind 80/443 and Rauthy sees a stable source IP), with a Gitea runner
on it, and the variables and secrets below set (`LOAD_TOKEN` is any
long random string: `openssl rand -hex 24`; Rauthy's are under
[Rauthy](#rauthy); the keys are under [The site's own network](#the-sites-own-network)):
```sh
git clone https://prosjekt.klingenbergbygg.no/tomtervel/infrastructure /srv/tomtervel/infrastructure
cd /srv/tomtervel/infrastructure
sudo install -m 0755 deploy-tomtervel /usr/local/bin/deploy-tomtervel # and the sudoers line in it
sudo ID_HOST=id.tomtervel.no sh bootstrap.sh # Kanidm's config and certificate
sudo install -m 0755 /srv/tomtervel/infrastructure/deploy-tomtervel /usr/local/bin/deploy-tomtervel # and the sudoers line in it
# Actions -> deploy -> Run workflow # the env files, and the stack up
sudo sh bootstrap.sh # recovers the Kanidm admins, once
sh kanidm-setup.sh # the portal client and desk groups; set the two secrets it names
```
`bootstrap.sh` prints the `admin` and `idm_admin` passwords once;
write them down. After `kanidm-setup.sh`, https://PORTAL_HOST serves the
site and https://ID_HOST is the login.
Then make the clients and portal's API key in Rauthy ([Rauthy](#rauthy)).
## Running on kasse (behind the host Caddy)
The vel keeps its **own** Kanidm and NATS here so it can later lift onto a host
of its own unchanged — on kasse it just runs in isolation, fronted by kasse's
existing host Caddy (which owns 80/443). So the bundled Caddy stays off (it's
behind `profiles: [edge]`); run the default `podman compose up -d --build`.
The services publish loopback-only ports for the host Caddy to reach:
On kasse the host Caddy already owns 80/443, so the bundled Caddy stays
off (`profiles: [edge]`). The services publish loopback-only ports for
it, and `host-caddy/tomtervel.no` is its file for them
(`/etc/caddy/conf.d/tomtervel.no`):
- portal → `127.0.0.1:3050`
- kanidm → `127.0.0.1:8443` (internal self-signed TLS)
- nats → `127.0.0.1:4223` (kasse's shared platform NATS owns 4222)
- kron → `127.0.0.1:3080`
- rauthy → `127.0.0.1:8090`
Add two host-Caddy site blocks in `/etc/caddy/conf.d/`, using the vel's `.env`
hosts (`vel.klingenbergbygg.no → :3050` already exists):
## Accounts and groups
```
<PORTAL_HOST> {
reverse_proxy localhost:3050
}
<ID_HOST> {
reverse_proxy https://localhost:8443 {
transport http { tls_insecure_skip_verify }
}
}
```
Rauthy holds the accounts: sign-in, passkeys, the account pages and the
account mail, in Norwegian. Portal signs in there
(`OIDC_ISSUER`), and portal makes the accounts there itself
(`RAUTHY_API_KEY`):
Then `sudo systemctl reload caddy`, point the content repo's `lint-and-reload`
reload step at `nats://127.0.0.1:4223`, and retire the old systemd portal:
`sudo systemctl disable --now app@tomtervel-portal`.
## Accounts, all the way
`kanidm-setup.sh` sets up everything portal needs from this Kanidm,
and is safe to rerun:
- **Desk groups, named as the content names them.** Read from every
`qualifies:` under `questions/` in the content repo, so the list
cannot drift from the pages. This Kanidm is the vel's own, so there is
no prefix: the board's group is `styret`. Groups from before are
renamed in place (`tomtervel_styret` → `styret`), members and all.
- **Sign-in.** The OAuth2 client's scope map is `idm_all_persons`:
everyone here is the vel's, and what they see is decided by their
desk groups in the `groups` claim.
- **Onboarding.** The `portal-onboarding` service account manages
every desk group, so an invite from a desk and a `grants:` can add
people to them. Its token goes into `portal.env`.
- **The first person in.** The `SEED_ADMIN_EMAIL` secret: at start,
portal invites them into the most privileged group (the board) and
mails the link, once. Everyone else they invite from their desk.
portal gives them the most privileged group (the board) and makes
their account; Rauthy mails them how to set a password or a passkey.
The same address is Rauthy's first admin.
- **Everyone else** is invited from a desk, or given a place by a case
(`grants:`). Portal makes the account if there is none, and Rauthy
mails the way in.
- **The people who ask the questions.** Everyone a page names as
`responsible` gets an account at start, a mail saying they are listed
as responsible for asking that question, and a place in
`RESPONSIBLE_GROUP` (`redaktor`). Signed in, they can suggest changes
to their own pages.
- **The project Gitea.** With `GITEA_URL` set, `redaktor` may sign in
to it with the same account: its own OAuth2 client, only for that
group. Run on the Gitea host, the script adds the sign-in source
itself (and requires the `redaktor` claim there too); elsewhere it
leaves the secret in `gitea-oauth.secret` and prints the one command.
`responsible` gets an account at start and a place in
`RESPONSIBLE_GROUP` (`redaktor`).
## People and desks
Each group in the content (`qualifies:` under `questions/`) is a
Kanidm group `tomtervel_<group>`, all members of `tomtervel_members`.
Someone in `tomtervel_styret` logs in and sees the board's desk.
```sh
kanidm -D idm_admin -H https://ID_HOST person create kari "Kari Lien"
kanidm -D idm_admin -H https://ID_HOST person update kari --mail kari@example.no
kanidm -D idm_admin -H https://ID_HOST person credential create-reset-token kari
kanidm -D idm_admin -H https://ID_HOST group add-members tomtervel_styret kari
```
Membership is read at login; someone added while logged in logs out
and in again.
The groups are kept in Rauthy (`PEOPLE_BACKEND=rauthy`): an invite
puts the person in the group there, and an invite is a case in
`portal_invites` until they come. Who is in `styret` is on the board's
desk, "Medlemmer og invitasjoner", where a person is taken out or invited
again. Portal decides what a group may do, on the site and in the chat's
rooms alike. Records in `portal_memberships` are left from before
(Kanidm); nothing new is written there.
## Content changes
A push to tomtervel/questions is linted on push and tells the portal
to reload over NATS. That reload reaches the host it runs on: today
Klingenberg Bygg's. On this host the runner is a **host service**
(`pacman -S gitea-runner`, registered against prosjekt.klingenbergbygg.no) —
not an in-compose container — so it reaches NATS on the published
`127.0.0.1:4222`. Give the content repo's `lint-and-reload.yml` a reload job
whose `runs-on` matches that runner's host label, running
`nats --server nats://portal:$NATS_PASSWORD@127.0.0.1:4222 pub portal.content.reload ""`.
Until then, `podman compose restart portal` picks up new content.
A push to tomtervel/questions is linted, and its CI then asks the site
to load that commit: `POST https://<PORTAL_HOST>/dhd/1/load` with the
org secret `LOAD_TOKEN`. The site fetches the commit, checks it whole
and swaps it in; if anything fails, the last good content goes on
serving, and the answer says why. The site is given the token's hash
alone (`DHD_TOKENS`, written by the deploy). It also reads the branch's
head every time it starts.
## The site's own network
gdo and kron dial the site over `dhd/1`; the site dials no one. They
know each other by key:
- **The site's key** is `site.key` beside its store, made the first
time a program is named. gdo and kron are told it, and where the site
listens, as `PORTAL_DHD=<site key>@127.0.0.1:4300`.
- **Each program's key** is in its own volume (`gdo_data`, `kron_data`),
made the first time it starts. The site names them, and what each may
do, in `DHD_KEYS=<gdo's key>=mail,note;<kron's key>=payments`.
Both are Actions variables (public keys; every start says them in the
log). `move-1.0/move.sh` makes the keys and prints the two values. A
program whose volume is lost gets a new key, which the site does not
know until `DHD_KEYS` names it: read it from the program's log.
They dial from loopback to loopback, so portal, gdo and kron share one
network namespace, which the `net` container holds (`compose.yml` says
why it is not portal's own). Tried on kasse, 2026-11-24: after a restart
of portal, and after it was made anew, gdo and kron dialled again within
half a minute and the mail and the payment that had waited went through.
## Upgrading portal
@@ -137,45 +119,191 @@ two cannot drift apart.
Every value the stack runs with is an Actions variable or secret in
Gitea, never a file in the repo (it is public) and never edited on the
host. The deploy workflow writes them into the env files on kasse
(`.env`, `portal.env`, `nats.env`, `chat.env`) on every run, so a host
(`.env`, `portal.env`, `kron.env`, `rauthy.env`) on every run, so a host
name or a version is changed in Gitea, and then **Actions -> deploy ->
Run workflow**. Set them with `gt` (`gt variable set NAME --body ...`,
`gt secret set NAME`, `-o tomtervel` for the org's).
| name | kind | where | what |
|---|---|---|---|
| `PORTAL_HOST`, `ID_HOST`, `CHAT_HOST` | variable | repo | the site, the login, the chat; each needs DNS (`dns/`) and a kasse Caddy block |
| `PORTAL_HOST`, `RAUTHY_HOST` | variable | repo | the site, the login; each needs DNS (`dns/`) and a kasse Caddy block |
| `PORTAL_RELEASE` | variable | **org** | a uhhm/portal tag; the content repo's lint reads the same one |
| `GDO_RELEASE`, `CNATS_TAG`, `KRON_RELEASE` | variable | repo | the mailer, the chat, the money service |
| `COMPOSE_PROFILES` | variable | repo | `chat` |
| `GDO_RELEASE`, `KRON_RELEASE` | variable | repo | the mailer's version as the [uhhm] registry has it (`v0.4.0` and on; the build fails when the registry's is another), and the money service's image tag (`0.3.0` and on): the ones that dial a 1.0 site |
| `COMPOSE_PROFILES` | variable | repo | `pay` |
| `DHD_KEYS`, `PORTAL_DHD` | variable | repo | the programs' keys and what each may do, and the site's key and address ([The site's own network](#the-sites-own-network)) |
| `PORTAL_BACKUP_TO`, `GARAGE_BACKUPS_BUCKET` | variable | repo | optional: an age public key and a bucket, for sealed copies of the store ([Backups](#backups)) |
| `CONTENT_REPO`, `CONTENT_BRANCH` | variable | repo | the content this site serves |
| `SITE_NAME` | variable | repo | `tomtervel`; never changed (a new name is a new, empty site) |
| `PEOPLE_BACKEND`, `RESPONSIBLE_GROUP` | variable | repo | `memberships`, `redaktor` |
| `OAUTH2_CLIENT_ID`, `CHAT_OAUTH2_CLIENT_ID` | variable | repo | the Kanidm clients of the site and the chat |
| `NATS_ADOPT_LEGACY` | variable | repo | `sole` |
| `SITE_NAME` | variable | repo | `tomtervel`; never changed (kron and the mail name the site by it) |
| `PEOPLE_BACKEND`, `RESPONSIBLE_GROUP` | variable | repo | `rauthy`, `redaktor` |
| `OAUTH2_CLIENT_ID` | variable | repo | the site's Rauthy client: `portal` |
| `GARAGE_S3_ENDPOINT`, `GARAGE_UPLOADS_BUCKET` | variable | repo | uploads |
| `NATS_PASSWORD` | secret | **org** | the stack's NATS; the content repo's reload uses it too |
| `OAUTH2_CLIENT_SECRET`, `KANIDM_API_TOKEN` | secret | repo | made by `kanidm-setup.sh`, which says how to set them |
| `CHAT_OAUTH2_CLIENT_SECRET` | secret | repo | the chat's Kanidm client |
| `LOAD_TOKEN` | secret | **org** | what the content repo's reload posts to the site; the site gets its hash |
| `OAUTH2_CLIENT_SECRET` | secret | repo | the site's Rauthy client |
| `GARAGE_ACCESS_KEY`, `GARAGE_SECRET_KEY` | secret | repo | uploads |
| `SEED_ADMIN_EMAIL`, `SEED_ADMIN_NAME` | secret | repo | the first person in; an address, so not a variable |
| `CLOUDFLARE_API_TOKEN` | secret | repo | DNS edit for tomtervel.no only (`dns/`) |
| `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_ENC_KEY`, `RAUTHY_SECRET_RAFT`, `RAUTHY_SECRET_API` | secret | repo | Rauthy's own: made once, never changed (the key encrypts its database) |
| `OIDC_ISSUER` | variable | repo | where the site signs in: `https://konto.tomtervel.no/auth/v1/` |
| `RAUTHY_BOOTSTRAP_API_KEY`, `RAUTHY_BOOTSTRAP_API_KEY_SECRET` | secret | repo | optional, Rauthy's first start only: a short-lived key (base64 of `{"name","exp","access"}`, secret 64+ alphanumerics) that makes the OIDC clients through the API; read into an empty database, ignored after |
| `RAUTHY_API_KEY`, `RAUTHY_LANGUAGE` | secret, variable | repo | portal makes accounts in Rauthy (`<name>$<secret>`, made in Rauthy's admin), in `nb` |
| `VIPPS_LOGIN_CLIENT_ID`, `VIPPS_LOGIN_CLIENT_SECRET` | variable, secret | repo | Vipps Login (the login sales unit's keys from portal.vippsmobilepay.no): the deploy keeps Vipps as a sign-in provider in Rauthy with them (`rauthy-providers.sh`) |
| `PAY_HOST` | variable | repo | where the money service answers: `betaling.tomtervel.no` (DNS in `dns/`, a kasse Caddy block) |
| `VIPPS_MSN` | variable | repo | the Medlemskap sales unit's merchant serial number, `1192072` |
| `VIPPS_CLIENT_ID`, `VIPPS_CLIENT_SECRET`, `VIPPS_SUBSCRIPTION_KEY` | secret | repo | the Medlemskap sales unit's ePayment keys (For developers, API keys, production), read by kron alone. With all four set kron asks the site for nothing |
| `VIPPS_WEBHOOK_SECRET` | secret | repo | what Vipps signs its webhooks with, from `vipps-webhook.sh register`; unset, kron refuses webhooks and asks Vipps about each open payment every minute instead |
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.
What is not a value stays on the host, made there once: Kanidm's config
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).
What is not a value stays on the host, made there once: Garage's node
secret.
## Colours in Rauthy
`rauthy-theme.sh` puts the site's palette (custom.css in the content
repo) on Rauthy's sign-in, account and admin pages, for Rauthy's own
client and the portal's, on every deploy. It needs the portal API key to
have Clients read and update; until it does, the step says so and
changes nothing, and the theme can be set by hand in the admin
(Clients, the client, Branding).
## Payments
The money service is [kron](https://project.uhhm.no/uhhm/kron), in the
stack under the `pay` profile (`COMPOSE_PROFILES=pay`). Portal
decides when money is owed: a household entering `open` or `fornyes` in
the content's aggregates owes the fee, and the request waits in the
site's `payments` outbox. kron dials the site, takes it, and answers
with a link of its own,
`https://betaling.tomtervel.no/pay/<reference>`, which portal shows on
the person's own page and mails; opening it makes a Vipps payment for
the Medlemskap sales unit and sends the person into Vipps, and a fresh
one each time the last ran out (Vipps's own expire after ten minutes).
Once they have paid, kron captures the reserved amount and tells the
site `paid`; portal moves the household to `betalt`, grants
`medlemmer`, and mails them. Vipps's keys live in `kron.env`: with all
four set kron asks the site for nothing. (kron can ask the site's
owners for them instead; that way is not tried here.) Portal never
holds a value and never calls Vipps. kron's ledger of what is being
paid is `kron.redb` in the `kron_data` volume. `PAY_URL` in
`portal.env` is what lets the content leave `by_hand: true` out of a
`payment:`; portal never calls that address either.
Going live, in order:
1. Set `PAY_HOST`, and the keys: `VIPPS_MSN` and the three key
secrets (table above; in `pass` as `tomtervel/vipps/medlemskap`). The host
script must know `kron.env` (this repo's `deploy-tomtervel`, optional
files): on kasse, `sudo install -m 0755 -o root -g root
/srv/tomtervel/infrastructure/deploy-tomtervel /usr/local/bin/deploy-tomtervel`
after the pull, since the installed copy does not update itself.
2. Merge the DNS record (`dns/dnsconfig.js`, `betaling`) and run the DNS
workflow; add the `betaling.tomtervel.no` block from
`host-caddy/tomtervel.no` to kasse's Caddy.
3. Set `COMPOSE_PROFILES=pay` and `KRON_RELEASE` (a uhhm/kron
version, `0.1.0`: the image is project.uhhm.no/uhhm/kron), then Run
workflow. `https://betaling.tomtervel.no/healthz`
answers `ok`.
4. Register the webhook: `./vipps-webhook.sh register` on a machine with
`pass` (it puts the secret in pass), then `gt secret set
VIPPS_WEBHOOK_SECRET` as it says, and Run workflow once more. Until
then kron settles by polling, a minute behind.
5. Drop `by_hand: true` from the content's `payment:` states (the
content repo's lint reads `PAY_URL` the same way).
Nothing here touches the Vippsnummer (500396): people may keep paying
there, and the treasurer marks those by hand as before.
## Rauthy
[Rauthy](https://github.com/sebadob/rauthy) at `RAUTHY_HOST`
(`konto.tomtervel.no`): sign-in, passkeys, account pages and account
mail, in Norwegian (`nb`) and English. A passkey belongs to the name it
was made on, so `RAUTHY_HOST` stays: a new name means new passkeys for
everyone.
On a new host:
1. The secrets, made once and never changed (the key encrypts its
database):
```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
```
Optionally a short-lived key for making the clients through the API
(`RAUTHY_BOOTSTRAP_API_KEY`, see the table), read on the first start
only.
2. Deploy. The first admin is `SEED_ADMIN_EMAIL`; its password is in the
log once: `podman compose logs rauthy | grep -A2 -i password`.
Signed in, it sets up a passkey.
3. In Rauthy's admin (`https://konto.tomtervel.no/auth/v1/admin`), or
with the bootstrap key: the client `portal` (`authorization_code`,
`S256`, scopes `openid profile email groups`, redirect
`https://tomtervel.no/auth/callback`; without `groups` Rauthy leaves
the groups out of the sign-in, and portal sees everyone in none: no
board, no committee) and `chat` (also
`refresh_token`, redirect `https://samtaler.tomtervel.no/auth/callback`),
their secrets into `OAUTH2_CLIENT_SECRET` and
`CHAT_OAUTH2_CLIENT_SECRET`, and an API key `portal` with read,
create and update on users, groups, roles and auth providers into `RAUTHY_API_KEY`
(a committee's leaders get a role that goes with managing it). A key
Rauthy no longer knows, or one past its expiry, answers 401 to
everything, and every invite fails ("the account could not be made
just now"; `rauthy: reading the groups: http 401` in the log).
Rauthy's mail leaves through kasse's postfix like gdo's, and Rauthy
stops if it cannot reach it.
## Previews
Every content branch pushed to tomtervel/questions gets its own preview
before it is merged, on `https://<branch>.forhandsvisning.tomtervel.no`,
for five days after its last push; `forhandsvisning.tomtervel.no` lists
the ones there are. The content repo runs them
(`.gitea/preview/preview.sh`, from `lint-and-reload` once the lint
passes): a container `tomtervel-preview-<branch>` from this site's own
image (`localhost/tomtervel-portal:<PORTAL_RELEASE>`), beside a throwaway
NATS (`tomtervel-preview-nats`) where each branch has a `SITE_NAME` of its
own, and a small Caddy, `tomtervel-preview-router` on 127.0.0.1:3066, that
picks the container by the name asked for. At most five run at once; the
one that expires first goes when a sixth arrives. The content repo's
`preview-cleanup` workflow removes them when they expire (hourly) and when
their branch is deleted.
A preview has no gdo, so nothing mails anyone, and no sign-in, so desks
stay shut and the public pages show. A form sent on it lands in the
throwaway NATS and nowhere else. The commit gets a "forhåndsvisning"
status with the link, which a PR shows among its checks. Main is never
previewed: it is the site.
On kasse this needs the DNS records in `dns/dnsconfig.js` (the bare name
and `*.forhandsvisning`), the two blocks in `host-caddy/tomtervel.no`, and
the `on_demand_tls` global option described there, in
`/etc/caddy/Caddyfile`.
## Backups
- Kanidm writes a nightly backup into its volume (`/data/backups`,
seven kept); copy that directory off the host.
- NATS JetStream data is the `nats_data` volume: every record ever
submitted and every state change. Snapshot the volume.
- **The site's store** is one file, `site.redb` in the `portal_data`
volume: every record and its history, the mail and payments that
wait, the sessions. With `PORTAL_BACKUP_TO` (an age public key, made
with `age-keygen` on a machine that is not this host; the private
half never comes here) and `GARAGE_BACKUPS_BUCKET` (a bucket the
site's garage key may write), the site seals a copy of it every six
hours and keeps the newest fourteen. **Neither is set yet**: until
they are, the volume is the only copy. To restore, stop the site and
put the opened copy in the store's place
(`age -d -i backup-key.txt <copy>.redb.age > site.redb`).
- Rauthy's database is the `rauthy_data` volume: the accounts, passkeys
and clients. Snapshot the volume.
- kron's ledger is the `kron_data` volume; gdo's key the `gdo_data`
one. A lost key is a new one named in `DHD_KEYS`.
- The uploads are the `garage_data` volume.
- `nats_data` is what portal 0.19 kept: it stays until going back is no
longer wanted (`move-1.0/README.md`).
- Caddy's certificates regenerate; nothing to keep.
## What is not here
@@ -195,8 +323,8 @@ it, the token it needs, and the order of a move are in
## Mail
Portal decides what to send - a `mail:` on a state in the content, or an
invite - and publishes it on this stack's NATS. `gdo` is what hands it to
a mail server, and it runs here, in the vel's own stack, so the vel's mail
invite - and keeps it in its `mail` outbox. `gdo` dials the site, is
handed what waits there, and hands it to a mail server, and it runs here, in the vel's own stack, so the vel's mail
leaves on the vel's own terms.
It has no mail server of its own. It relays through the host's, which on
@@ -212,51 +340,6 @@ Replies are not read yet: `JMAP_URL`, `JMAP_TOKEN` and `MAIL_REPLY_DOMAIN`
turn a reply into a note on the record it answers, and none of them are set
here.
## How the login page looks
Out of the box Kanidm presents itself: its own name, its own mark. A
neighbour arriving at a login page that belongs to nobody in particular
is right to hesitate, so `kanidm-setup.sh` sets the vel's name and mark
on both the instance and the portal client:
```sh
kanidm -D idm_admin -H https://$ID_HOST system domain set-displayname "Tomter Vel"
kanidm -D idm_admin -H https://$ID_HOST system domain set-image logo.svg svg
```
The logo is fetched from the content repo - the same `images/logo.svg`
that `site.yaml` uses as the favicon - so the login page and the site
are branded from one place. png, jpg, gif, svg and webp all work.
Two things the setup script deliberately leaves alone, because they are
decisions rather than branding:
- `system domain set-allow-account-recovery true` lets someone who has
lost their credentials get a reset link by proving one of their own
email addresses, instead of asking the board. Worth having for a vel;
it is still a door, so it is turned on knowingly or not at all.
- `system domain set-allow-easter-eggs` - seasonal icons and birthday
surprises. Off in production builds, and this is somebody's vel.
## Keep the CLI and the server on the same version
The `kanidm` CLI on the host and the `kanidm/server` image in
`compose.yml` must match. They are not merely fussy about it: a 1.11.2
client against a 1.11.1 server looks up the domain entry at a UUID the
older server does not have, so `system domain set-displayname` and
`set-image` fail with "Item not found" - a message that says nothing
about versions. The CLI warns on every call; the warning is worth
reading.
The same "Item not found" also comes back when the versions do match
and the account is `idm_admin`: the instance's own name and logo are
system settings only `admin` may change. `kanidm-setup.sh` sets them
when an `admin` session exists and says so when it does not.
The host's CLI comes from pacman and moves on its own, so the image is
what to bump: `image: kanidm/server:<version>` in `compose.yml`, then
`podman compose up -d kanidm`.
## Mail leaving the host
gdo hands the vel's mail to kasse's own postfix over the container
-51
View File
@@ -1,51 +0,0 @@
#!/bin/sh
# What a fresh host needs before the first deploy, and what only exists
# after it. Everything the stack runs with is an Actions variable or
# secret (README.md), written onto the host by the deploy workflow; this
# makes the two things that are not values: Kanidm's config and its
# internal certificate. Idempotent: rerunning skips what exists.
#
# sudo ID_HOST=id.tomtervel.no sh bootstrap.sh # before the first deploy
# (Actions -> deploy -> Run workflow)
# sudo sh bootstrap.sh # after: Kanidm admin recovery
#
# Run rootful (as root) so Kanidm sees a stable source IP.
set -eu
cd "$(dirname "$0")"
[ -f .env ] && . ./.env
: "${ID_HOST:?ID_HOST=id.<the vel's domain> sh bootstrap.sh, or run the deploy workflow first}"
# Kanidm's domain is fixed here, once: renaming it later is Kanidm's own
# `domain rename`, not a variable changed.
[ -f kanidm/server.toml ] || {
sed "s|\${ID_HOST}|$ID_HOST|g" kanidm/server.toml.tpl > kanidm/server.toml
echo "kanidm/server.toml made for $ID_HOST"
}
# Kanidm's internal certificate: Caddy holds the public one.
mkdir -p certs
if [ ! -f certs/kanidm-key.pem ]; then
openssl req -x509 -newkey rsa:2048 -nodes -days 3650 \
-subj "/CN=kanidm" -addext "subjectAltName=DNS:kanidm,DNS:$ID_HOST" \
-keyout certs/kanidm-key.pem -out certs/kanidm-chain.pem >/dev/null 2>&1
chmod 600 certs/kanidm-key.pem
echo "internal Kanidm certificate made"
fi
# The Kanidm admin accounts exist only after the first start; their
# passwords are set by recovery. Once; the output is the password, shown
# once.
if ! podman compose ps --format '{{.Names}}' 2>/dev/null | grep -q kanidm; then
echo "Kanidm is not running yet: run the deploy workflow, then this again."
exit 0
fi
if [ ! -f .kanidm-recovered ]; then
echo
echo "=== Kanidm admin recovery (write these passwords down) ==="
podman compose exec kanidm kanidmd recover-account admin
podman compose exec kanidm kanidmd recover-account idm_admin
touch .kanidm-recovered
fi
echo
echo "Next: sh kanidm-setup.sh (log in as idm_admin, create the portal client and desk groups)"
+159 -95
View File
@@ -1,16 +1,17 @@
# Tomter Vel's own platform: portal + its own Kanidm and NATS as podman
# containers. The content (pages, forms, desks) is not here: portal fetches
# it from tomtervel/questions on prosjekt.klingenbergbygg.no and hot-reloads
# it over NATS. This repo owns identity, the bus, and which portal version
# runs. TLS depends on where it runs: on a standalone host the bundled Caddy
# (`--profile edge`) terminates it; on kasse the host Caddy already owns
# 80/443 and reverse-proxies vel.klingenbergbygg.no -> portal (127.0.0.1:3050).
# Tomter Vel's own platform: portal, its own Rauthy, and the programs
# beside the site (gdo for mail, kron for Vipps) as podman containers.
# The content (pages, forms, desks) is not here: portal fetches it from
# tomtervel/questions on prosjekt.klingenbergbygg.no, at start and when
# that repo's CI asks it to (POST /dhd/1/load). This repo owns identity,
# which portal version runs, and where the site keeps what is its own:
# one file, in the volume portal_data. TLS depends on where it runs: on a
# standalone host the bundled Caddy (`--profile edge`) terminates it; on
# kasse the host Caddy already owns 80/443 and reverse-proxies
# tomtervel.no -> portal (127.0.0.1:3050).
#
# bootstrap.sh first time on a fresh host: renders configs from
# .env, makes Kanidm's internal cert, starts it all,
# recovers the Kanidm admin, creates the portal client
# and desk groups.
# podman compose up -d --build every time after that.
# Everything it runs with is an Actions variable or secret, written by
# the deploy workflow (README.md); `podman compose up -d --build` is
# what deploy-tomtervel runs.
name: tomtervel
@@ -29,63 +30,96 @@ services:
- "443:443/udp"
environment:
PORTAL_HOST: ${PORTAL_HOST}
ID_HOST: ${ID_HOST}
RAUTHY_HOST: ${RAUTHY_HOST}
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
depends_on:
- portal
- kanidm
- rauthy
# The NATS portal 0.19 kept everything on. Nothing of the 1.0 stack
# reads it: it is here, behind a profile nothing turns on, so its
# container and its volume (nats_data) stay as they are for as long as
# going back to 0.19 should be possible (move-1.0/README.md). Take it
# out, and the volume, once it is not.
nats:
profiles: ["nats-0-19"]
image: nats:2.14.6-alpine
restart: unless-stopped
command: ["-c", "/etc/nats/nats.conf"]
# NATS_PASSWORD, which nats.conf reads from the environment.
env_file: nats.env
env_file:
- path: nats.env
required: false
volumes:
- ./nats/nats.conf:/etc/nats/nats.conf:ro
- nats_data:/data
# Published on the host so the reload job (`nats pub portal.content.reload ""`)
# can reach it; password-protected (see nats.conf). Host port 4223, not 4222:
# on kasse the shared platform NATS already owns 127.0.0.1:4222 and the vel
# runs its own NATS in isolation, so the reload workflow targets 4223 there.
# (Standalone, nothing else owns 4222, but 4223 is harmless.)
ports:
- "127.0.0.1:4223:4222"
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8222/healthz"]
interval: 10s
timeout: 5s
retries: 3
kanidm:
image: kanidm/server:1.11.2
# Rauthy: who is who. Sign-in, account pages and account mail, in
# Norwegian; portal signs in here (OIDC_ISSUER) and portal
# makes accounts here (RAUTHY_API_KEY). Its database is embedded
# (hiqlite), in rauthy_data. Host-published for kasse's host Caddy
# (RAUTHY_HOST -> here).
rauthy:
image: ghcr.io/sebadob/rauthy:${RAUTHY_TAG:-0.37.2}
restart: unless-stopped
env_file:
- path: rauthy.env
required: false
environment:
KANIDM_CONFIG_PATH: /data/server.toml
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:
- kanidm_data:/data
- ./kanidm/server.toml:/data/server.toml:ro
# Internal self-signed TLS: Caddy terminates the public
# certificate and proxies here without verification.
- ./certs/kanidm-chain.pem:/data/chain.pem:ro
- ./certs/kanidm-key.pem:/data/key.pem:ro
# Standalone (--profile edge): only the bundled Caddy talks to Kanidm.
# On kasse the host Caddy fronts it, so publish loopback-only for a conf.d
# entry: id.<vel> { reverse_proxy https://localhost:8443 {
# transport http { tls_insecure_skip_verify } } }
# (Kanidm's internal self-signed cert; 8443 is free on kasse — its shared
# Kanidm is on 8310.)
- ./rauthy/config.toml:/app/config.toml:ro
- rauthy_data:/app/data
ports:
- "127.0.0.1:8443:8443"
- "127.0.0.1:8090:8080"
# The network the site and the programs beside it share. gdo and kron
# dial the site from loopback to loopback (DHD_BIND, 127.0.0.1:4300
# unless set), so the three must be in one network namespace, and it
# must outlive each of them: held by portal itself, a restart of portal
# left gdo and kron in the namespace it had, cut off, until they were
# made anew. This container does nothing but hold it. What any of the
# three needs of the network is said here: the published ports, the
# way to the host's mail server, and the name `portal` on the project's
# network.
net:
image: docker.io/library/alpine:3.22
restart: unless-stopped
command: ["sleep", "infinity"]
# sleep as the first process hears no SIGTERM.
stop_signal: SIGKILL
extra_hosts:
- "host.containers.internal:host-gateway"
networks:
default:
aliases:
- portal
ports:
# Host-published for kasse's host Caddy (tomtervel.no -> portal).
# With --profile edge the bundled Caddy proxies portal:3000
# internally instead, but publishing loopback-only is harmless
# there.
- "127.0.0.1:3050:3000"
# kron (betaling.tomtervel.no -> here).
- "127.0.0.1:3080:3080"
portal:
build:
context: ./portal
args:
PORTAL_RELEASE: ${PORTAL_RELEASE}
# Named, so the content repo's preview (tomtervel/questions,
# lint-and-reload.yml) runs the very image this site runs.
image: localhost/tomtervel-portal:${PORTAL_RELEASE}
restart: unless-stopped
# Written by the deploy workflow from the Actions variables and
# secrets (README.md has the table).
@@ -96,80 +130,107 @@ services:
LEPTOS_HASH_FILES: "true"
LEARN_CACHE: /app/learn-cache
OLLAMA_HOST: http://100.64.0.1:11434
# The namespace of everything this site keeps on NATS from portal 0.9.
# Must not change: a new name is a new, empty site.
# What the site calls itself to the programs beside it. Must not
# change: kron and the mail name the site by it.
SITE_NAME: tomtervel
# Everything the site keeps: its records and their history, the
# mail and payments that wait, the sessions. One file, opened by
# this container alone; site.key beside it is the site's key on
# dhd/1. A new volume is a new, empty site.
PORTAL_STORE: /data/site.redb
volumes:
- learn_cache:/app/learn-cache
ports:
# Host-published for kasse's host Caddy (vel.klingenbergbygg.no -> here).
# With --profile edge the bundled Caddy proxies portal:3000 internally
# instead, but publishing loopback-only is harmless there.
- "127.0.0.1:3050:3000"
- portal_data:/data
network_mode: "service:net"
depends_on:
nats:
condition: service_healthy
kanidm:
net:
condition: service_started
rauthy:
condition: service_started
# The mailer. Portal decides what to send - a `mail:` on a state in the
# content, or an invite - and publishes it on this NATS; gdo is what
# actually hands it to a mail server. It is in the vel's own stack rather
# than shared, so the vel's mail leaves on the vel's own terms, but it
# has no mail server of its own: it relays through the host's, which on
# kasse is Klingenberg Bygg's postfix on port 25. That is the one thing
# here the vel borrows.
# content, or an invite - and keeps it in its own `mail` outbox; gdo
# dials the site over dhd/1 (PORTAL_DHD), is handed what waits there,
# and hands each to a mail server. It has none of its own: it relays
# through the host's, which on kasse is Klingenberg Bygg's postfix on
# port 25. That is the one thing here the vel borrows.
#
# The site must name gdo's key in DHD_KEYS as `<key>=mail,note`; gdo
# says the key as it starts, and move-1.0/move.sh reads it out.
gdo:
build:
context: ./gdo
args:
GDO_RELEASE: ${GDO_RELEASE}
# Named, so move-1.0/move.sh can start it once to read its key.
image: localhost/tomtervel-gdo:${GDO_RELEASE}
restart: unless-stopped
# NATS_URL, with the password: made by bootstrap.sh, never committed.
env_file: nats.env
network_mode: "service:net"
environment:
# The host, from inside the container. Podman resolves this to the
# gateway; the host's postfix listens on 0.0.0.0:25.
PORTAL_DHD: ${PORTAL_DHD:-}
# Its key on dhd/1, kept across rebuilds: a new key is one the
# site does not know.
GDO_KEY: /var/lib/gdo/gdo.key
# Set, so gdo sends through it and asks the site's owners for
# nothing. The host, from inside the container: podman resolves
# this to the gateway (extra_hosts on net); the host's postfix
# listens on 0.0.0.0:25.
SMTP_HOST: host.containers.internal
SMTP_PORT: "25"
# A strict server refuses a bare container hostname in EHLO.
SMTP_HELO: ${PORTAL_HOST}
extra_hosts:
- "host.containers.internal:host-gateway"
volumes:
- gdo_data:/var/lib/gdo
depends_on:
nats:
condition: service_healthy
- portal
# The Gitea Actions runner is a host service on kasse (pacman gitea-runner),
# registered against prosjekt.klingenbergbygg.no. It reaches this NATS via the
# published 127.0.0.1:4222 port above, so no in-compose runner — and no
# docker.sock/podman.sock mount — is needed here.
# The vel's conversations: every group the content names is a room,
# portal speaks in them and decides who gets in. Its history is on the
# vel's own NATS (stream tomtervel_CHAT); there is no Postgres. A
# profile, since it needs chat.env: go-live sets COMPOSE_PROFILES=chat
# in .env once it is there. Host-published for kasse's host Caddy
# (chat.vel.klingenbergbygg.no -> here).
cnats:
profiles: ["chat"]
image: docker.io/bendik/cnats:${CNATS_TAG:-no-tag-set}
# The money service (uhhm/kron): a household that owes its fee waits
# in portal's `payments` outbox; kron dials the site over dhd/1, takes
# the request, gives it a link to pay by, talks to Vipps's ePayment API
# for the Medlemskap sales unit, and tells the site `paid` as a move on
# the payment. Vipps's keys are in kron.env and nowhere else; portal
# never calls Vipps. Its ledger is a file of its own in kron_data.
# Reached by kasse's host Caddy on the published 3080
# (betaling.tomtervel.no): the pay links, the page people come back to
# from Vipps, and Vipps's webhooks. A profile, since it needs kron.env:
# COMPOSE_PROFILES has `pay` once the keys are set.
#
# The site must name kron's key in DHD_KEYS as `<key>=payments`.
kron:
profiles: ["pay"]
image: project.uhhm.no/uhhm/kron:${KRON_RELEASE:-no-tag-set}
restart: unless-stopped
network_mode: "service:net"
env_file:
- nats.env
- path: chat.env
required: false
- kron.env
environment:
# Must be the portal's own: a new name is a new, empty chat.
PORTAL_DHD: ${PORTAL_DHD:-}
# Must be the portal's own: a request names its site.
SITE_NAME: tomtervel
KANIDM_URL: https://${ID_HOST}
PUBLIC_URL: https://${CHAT_HOST}
COOKIE_SECURE: "true"
ports:
- "127.0.0.1:3070:3000"
PROVIDER: vipps
VIPPS_ENV: prod
PUBLIC_URL: https://${PAY_HOST:-no-host-set}
# 3080, not 3000: in the shared network 3000 is portal's.
LISTEN_ADDR: 0.0.0.0:3080
# Its key on dhd/1 and, beside it, its ledger (kron.redb).
KRON_KEY: /var/lib/kron/kron.key
# With the four VIPPS_* in kron.env kron asks the site for
# nothing, and this identity is not used.
KRON_IDENTITY_FILE: /var/lib/kron/identity
KRON_LANG: nb
volumes:
- kron_data:/var/lib/kron
depends_on:
nats:
condition: service_healthy
- portal
# The Gitea Actions runner is a host service on kasse (pacman
# gitea-runner), registered against prosjekt.klingenbergbygg.no. The
# content repo's reload reaches the site over HTTPS, so no in-compose
# runner - and no docker.sock/podman.sock mount - is needed here.
# The vel's conversations are not in this stack for now: the chat that
# ran here (cnats) spoke to portal over NATS, and the one that dials a
# 1.0 site (uhhm/kino) is not published as an image yet.
# Where uploads go: the pictures and documents a desk attaches, and what
# `portal import` brings in. One node on this host, reachable only inside
@@ -185,15 +246,18 @@ services:
volumes:
garage_data:
portal_data:
gdo_data:
kron_data:
caddy_data:
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
# trust (kanidm/server.toml.tpl) stays valid under Podman — its default pool
# hands out 10.89.x addresses that Caddy's forwarded client IP can't match.
# Pin the project network subnet inside 172.16/12 so Rauthy's trusted
# proxies (rauthy/config.toml) stay valid under Podman — its default pool
# hands out 10.89.x addresses that the forwarded client IP can't match.
networks:
default:
ipam:
+9 -1
View File
@@ -17,7 +17,10 @@ set -euo pipefail
root=/srv/tomtervel/infrastructure
stage=/var/lib/gitea-runner/tomtervel-env
files=(.env portal.env nats.env chat.env)
files=(.env portal.env)
# Written only when the site runs what needs it (Rauthy, the money
# service under the pay profile).
optional=(rauthy.env kron.env)
[ -d "$root/.git" ] || { echo "no checkout at $root - bootstrap it first" >&2; exit 1; }
for f in "${files[@]}"; do
@@ -32,6 +35,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
+4 -4
View File
@@ -60,10 +60,10 @@ Nothing about Zoho's MX should appear.
prints its public half. Put it in `KASSE_DKIM`.
2. Actions -> dns -> Run workflow on main (or `dnscontrol push`). The apex
leaves the old website at this moment.
3. The Actions variables `PORTAL_HOST=tomtervel.no`, `ID_HOST=id.tomtervel.no`,
`CHAT_HOST=chat.tomtervel.no`, the deploy workflow run, and the Caddy blocks in
`host-caddy/` on kasse; Kanidm's domain is renamed before anyone
but the first person has a passkey.
3. The Actions variables `PORTAL_HOST=tomtervel.no`, `RAUTHY_HOST=konto.tomtervel.no`,
`CHAT_HOST=samtaler.tomtervel.no`, the deploy workflow run, and the Caddy blocks in
`host-caddy/` on kasse. `RAUTHY_HOST` is chosen once: a passkey belongs
to the name it was made on.
4. Only then `mail.from: post@tomtervel.no` in the content repo's
`site.yaml`; before step 2 that mail fails every check.
+20 -2
View File
@@ -12,7 +12,7 @@ var REG_NONE = NewRegistrar("none");
var DSP_CLOUDFLARE = NewDnsProvider("cloudflare");
// kasse: Klingenberg Bygg's host, where the vel's stack runs (portal,
// Kanidm, chat, gdo) behind kasse's own Caddy, and whose postfix sends
// Rauthy, chat, gdo) behind kasse's own Caddy, and whose postfix sends
// the vel's mail. Move the vel to a host of its own: change this.
var KASSE = "195.159.177.252";
@@ -30,8 +30,20 @@ D("tomtervel.no", REG_NONE, DnsProvider(DSP_CLOUDFLARE),
// websockets reach it as they are.
A("@", KASSE, CF_PROXY_OFF),
CNAME("www", "tomtervel.no.", CF_PROXY_OFF),
A("konto", KASSE, CF_PROXY_OFF),
// The money service (kron): pay links and Vipps's webhooks.
A("betaling", KASSE, CF_PROXY_OFF),
A("samtaler", KASSE, CF_PROXY_OFF),
// The old names, kept so links from before still land: Caddy sends
// id on to konto (the login) and chat on to samtaler.
A("id", KASSE, CF_PROXY_OFF),
A("chat", KASSE, CF_PROXY_OFF),
// The content repo's previews: the list of them, and one name per
// branch before it is merged (<branch>.forhandsvisning). Caddy gets a
// certificate for a branch's name the first time it is asked for, and
// only for a branch that has a preview (host-caddy/tomtervel.no).
A("forhandsvisning", KASSE, CF_PROXY_OFF),
A("*.forhandsvisning", 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
@@ -51,7 +63,13 @@ D("tomtervel.no", REG_NONE, DnsProvider(DSP_CLOUDFLARE),
// Reports only, to start. Tighten to p=quarantine once the reports
// show both Zoho and kasse passing.
TXT("_dmarc", "v=DMARC1; p=none; rua=mailto:post@tomtervel.no"),
//
// The reports (a daily XML file from each large mailbox provider) go
// to dmarc@, not the board's post@. dmarc@ is an address at Zoho, made
// in Zoho Mail's admin before this is pushed: otherwise they bounce.
// Another domain in rua= needs its own consent record there
// (tomtervel.no._report._dmarc.<that domain>).
TXT("_dmarc", "v=DMARC1; p=none; rua=mailto:dmarc@tomtervel.no"),
// Zoho's DKIM key, as it stands today: on the zone's apex, where no
// receiver looks for it, so mail from Zoho is unsigned in effect. Zoho
+15 -5
View File
@@ -2,6 +2,11 @@
# bare-metal hosts install. Arch base rather than Debian because that is
# how every uhhm binary is published; portal ships a release tarball and
# is built from that instead.
#
# GDO_RELEASE is the version the site runs (v0.4.0 or later: 0.4 is the
# first that dials a portal 1.0 site). The registry serves one version,
# its newest, so the build checks that what it installed is the one
# named, and fails when the variable has fallen behind the registry.
FROM archlinux:base
ARG GDO_RELEASE
@@ -15,7 +20,8 @@ ARG GDO_RELEASE
# good enough, but then nothing would notice a package that host did
# not sign. Locally signed, the check stays real.
COPY uhhm-registry.asc /tmp/uhhm-registry.asc
RUN pacman-key --init \
RUN test -n "$GDO_RELEASE" \
&& pacman-key --init \
&& pacman-key --populate archlinux \
&& pacman-key --add /tmp/uhhm-registry.asc \
&& pacman-key --lsign-key 1BCBE90F04AD9859D7BCC9BB53CBF90AA4C56211 \
@@ -25,12 +31,16 @@ RUN pacman-key --init \
'SigLevel = Required DatabaseOptional' \
'Server = https://project.uhhm.no/api/packages/bl/arch/$repo/$arch' \
>> /etc/pacman.conf \
&& pacman -Sy --noconfirm --needed ca-certificates gdo \
&& pacman -Syu --noconfirm --needed ca-certificates gdo \
&& have=$(pacman -Q gdo | cut -d' ' -f2 | cut -d- -f1) \
&& { [ "$have" = "${GDO_RELEASE#v}" ] || { echo "the registry has gdo $have, GDO_RELEASE says $GDO_RELEASE" >&2; exit 1; }; } \
&& pacman -Scc --noconfirm \
&& rm -rf /var/cache/pacman/pkg/* /var/lib/pacman/sync/*
# A non-root user; gdo writes nothing and holds no state - what it has
# not yet delivered is on the stream, not on disk.
RUN useradd --system --no-create-home gdo
# A non-root user. gdo keeps its key on dhd/1 in /var/lib/gdo, a volume
# (GDO_KEY in compose.yml); what it has not yet delivered waits with the
# site, not here.
RUN useradd --system --no-create-home gdo \
&& mkdir -p /var/lib/gdo && chown gdo /var/lib/gdo && chmod 700 /var/lib/gdo
USER gdo
CMD ["/usr/bin/gdo"]
+75
View File
@@ -0,0 +1,75 @@
# kasse's host Caddy: /etc/caddy/conf.d/tomtervel.no. The vel's own
# names, in dns/dnsconfig.js, pointing here unproxied; Caddy gets their
# certificates itself as soon as the records point here. The same as the
# vel.klingenbergbygg.no blocks beside it, which stay until the move is
# done.
tomtervel.no {
reverse_proxy 127.0.0.1:3050
}
www.tomtervel.no {
redir https://tomtervel.no{uri} permanent
}
# The old login, Kanidm, is gone: its name sends people on to Rauthy.
id.tomtervel.no {
redir https://konto.tomtervel.no permanent
}
# The vel's conversations (cnats). Its old name sends people on, so a
# link or a bookmark from before still lands.
samtaler.tomtervel.no {
reverse_proxy 127.0.0.1:3070
}
chat.tomtervel.no {
redir https://samtaler.tomtervel.no{uri} permanent
}
# Rauthy: sign-in, passkeys and account pages, in Norwegian (README.md,
# "Rauthy"). Plain http on a loopback port; Caddy holds the certificate.
konto.tomtervel.no {
reverse_proxy 127.0.0.1:8090
}
# The money service (kron, README.md "Payments"): the pay links portal
# gives out, the page people come back to from Vipps, and Vipps's
# webhooks. Kept out of search engines; nothing here is a page to find.
betaling.tomtervel.no {
header X-Robots-Tag "noindex, nofollow"
reverse_proxy 127.0.0.1:3080
}
# The content repo's previews (tomtervel/questions, .gitea/preview/): one
# portal per branch on <branch>.forhandsvisning.tomtervel.no, for five days
# after its last push, and the list of them on the bare name. Every name
# goes to the previews' own router on 3066, which picks the branch's
# container by name. Kept out of search engines.
#
# A branch's name has no certificate until someone opens it: Caddy gets one
# on demand, and first asks the router whether that name has a preview, so
# made-up names cannot use up Let's Encrypt's limits. That needs this in the
# global options of /etc/caddy/Caddyfile (kasse's, shared with the other
# sites there; nothing else on kasse uses on-demand TLS):
#
# on_demand_tls {
# ask http://127.0.0.1:3066/ask
# }
#
# Port 3066: 3060 is gullberg.klingenbergbygg.no's, 3065 was the single
# preview before, and podman's own published ports (3050, 3065, 3066, 3070,
# 8090) do not show in `ss`, so a port is chosen against this directory's
# upstreams as well.
forhandsvisning.tomtervel.no {
header X-Robots-Tag "noindex, nofollow"
reverse_proxy 127.0.0.1:3066
}
*.forhandsvisning.tomtervel.no {
tls {
on_demand
}
header X-Robots-Tag "noindex, nofollow"
reverse_proxy 127.0.0.1:3066
}
-202
View File
@@ -1,202 +0,0 @@
#!/bin/sh
# Everything portal needs from this Kanidm, all the way: the OAuth2
# client people sign in through, one group per desk named exactly as
# the content names it, and the service account portal onboards people
# with - so that inviting someone from a desk, a decision that grants a
# group, and the first person in (SEED_ADMIN_EMAIL) all simply work.
# Rerunnable: each step skips what is already there.
#
# Logs in first if needed (interactive, idm_admin's password from
# bootstrap.sh), writes the client secret and the onboarding token into
# portal.env, and restarts portal. Needs the kanidm CLI and curl.
set -eu
cd "$(dirname "$0")"
. ./.env
. ./portal.env
# The project Gitea that RESPONSIBLE_GROUP signs in to. Not an Actions
# variable: Gitea refuses names starting GITEA_. Empty: no Gitea.
GITEA_URL=${GITEA_URL-https://prosjekt.klingenbergbygg.no}
GITEA_AUTH_NAME=${GITEA_AUTH_NAME:-tomtervel}
K="kanidm -D idm_admin -H https://$ID_HOST"
C=$OAUTH2_CLIENT_ID
SA=portal-onboarding
# What a person reads on the sign-in pages. Not SITE_NAME, which from portal
# 0.9 is the site's namespace, `tomtervel`.
SITE_TITLE=${SITE_TITLE:-Tomter Vel}
# Already signed in? Then do not ask again: this script is meant to be
# rerunnable, and the session outlives a single run.
$K self whoami >/dev/null 2>&1 || $K login
has_client() { $K system oauth2 get "$1" 2>/dev/null | grep -q '^name:'; }
has_group() { $K group get "$1" 2>/dev/null | grep -q '^name:'; }
has_account() { $K service-account get "$1" 2>/dev/null | grep -q '^name:'; }
# The desk groups are whatever the content gates pages on: every
# `qualifies:` under questions/ in the content repo. Read from the repo,
# so this list cannot drift from the pages. This Kanidm is the vel's
# own, so a group is called exactly what the content calls it.
host=$(printf '%s' "$CONTENT_REPO" | sed -E 's|^(https?://[^/]+)/.*|\1|')
path=$(printf '%s' "$CONTENT_REPO" | sed -E 's|^https?://[^/]+/||')
tree=$(curl -sf "$host/api/v1/repos/$path/git/trees/$CONTENT_BRANCH?recursive=true&per_page=1000") || {
echo "could not read the content repo's file list ($CONTENT_REPO)" >&2; exit 1; }
groups=$(printf '%s' "$tree" | grep -oE '"path":"questions/[^"]+\.yaml"' | sed -E 's/^"path":"//; s/"$//' | while read -r f; do
curl -sf "$CONTENT_REPO/raw/branch/$CONTENT_BRANCH/$f" | sed -nE 's/^qualifies:[[:space:]]*"?([a-z0-9_-]+)"?[[:space:]]*$/\1/p'
done | sort -u)
[ -n "$groups" ] || { echo "the content gates no page on a group - nothing for a desk to sign in to" >&2; exit 1; }
echo "desk groups from the content: $(echo $groups)"
# The onboarding account. In idm_people_on_boarding it may create a
# person and issue a first credential reset and nothing else, so its
# token cannot touch anyone's existing credentials; idm_people_pii_read
# lets an invite find someone who already has an account by their
# email and add them instead of making a second account. Portal creates
# the person with their address in the same call, because this account
# may create but not modify.
if ! has_account $SA; then
$K service-account create $SA "Portal onboarding" idm_admin
fi
$K group add-members idm_people_on_boarding $SA >/dev/null
$K group add-members idm_people_pii_read $SA >/dev/null || true
# One group per desk, managed by the onboarding account: adding a
# member to a group takes the right to manage that group, and a desk
# invite or a `grants:` does exactly that. Groups made before this
# script dropped its old `tomtervel_` prefix are renamed in place, so
# their members and claim maps come along.
for g in $groups; do
if ! has_group "$g" && has_group "tomtervel_$g"; then
$K group rename "tomtervel_$g" "$g"
fi
has_group "$g" || $K group create "$g" $SA
$K group set-entry-manager "$g" $SA >/dev/null
done
# The people who ask the questions: everyone a page names as
# responsible. Portal puts them here itself at start (RESPONSIBLE_GROUP);
# the group only has to exist and be portal's to fill. Kanidm names are
# ASCII, so "Redaktør" is its description.
if [ -n "${RESPONSIBLE_GROUP:-}" ]; then
has_group "$RESPONSIBLE_GROUP" || $K group create "$RESPONSIBLE_GROUP" $SA
$K group set-entry-manager "$RESPONSIBLE_GROUP" $SA >/dev/null
$K group set-description "$RESPONSIBLE_GROUP" "${RESPONSIBLE_GROUP_LABEL:-Redaktør}: står som ansvarlig for et spørsmål på siden" >/dev/null || true
fi
# The OAuth2 client. Everyone in this Kanidm is the vel's, so anyone
# may sign in; what they see is decided by their desk groups, which
# arrive in the `groups` claim under their own names.
has_client $C || $K system oauth2 create $C "$SITE_TITLE" "https://$PORTAL_HOST"
$K system oauth2 add-redirect-url $C "https://$PORTAL_HOST/auth/callback" 2>/dev/null || true
$K system oauth2 update-scope-map $C idm_all_persons openid profile email
for g in $groups; do
$K system oauth2 update-claim-map $C groups "$g" "$g"
done
$K system oauth2 update-claim-map-join $C groups array
# The old umbrella group the scope map used to name, if this Kanidm
# still has it: idm_all_persons does its job now.
if has_group tomtervel_members; then
$K system oauth2 delete-scope-map $C tomtervel_members 2>/dev/null || true
$K group delete tomtervel_members
fi
# What a member sees when they land on the login page. Out of the box
# Kanidm says "kanidm" and shows its own mark, which tells a neighbour
# nothing about whose site they are signing in to. The logo comes from
# the content repo, the same file site.yaml uses as the favicon.
#
# The client's name and logo are idm_admin's to set. The instance's own
# (the login page's heading and mark) are system settings only `admin`
# may change - idm_admin gets a bare "Item not found" - so that half
# runs when an admin session exists, and otherwise says what to run.
A="kanidm -D admin -H https://$ID_HOST"
$K system oauth2 set-displayname $C "$SITE_TITLE" >/dev/null || true
logo=$(mktemp --suffix=.svg)
if curl -sfL "$CONTENT_REPO/raw/branch/$CONTENT_BRANCH/images/logo.svg" -o "$logo" && [ -s "$logo" ]; then
$K system oauth2 set-image $C "$logo" svg >/dev/null || echo "note: could not set the client logo"
else
echo "note: no images/logo.svg in the content repo - leaving the default mark"
: > "$logo"
fi
if $A self whoami >/dev/null 2>&1; then
$A system domain set-displayname "$SITE_TITLE" >/dev/null || echo "note: could not set the login page's name"
[ -s "$logo" ] && { $A system domain set-image "$logo" svg >/dev/null || echo "note: could not set the login page's logo"; }
else
echo "note: the login page's own name and logo need the admin account (bootstrap.sh printed its password):"
echo " $A login # then rerun this script"
fi
rm -f "$logo"
# Sign-in to a project Gitea for the people who ask the questions: its
# own OAuth2 client, which only RESPONSIBLE_GROUP may use, carrying that
# group in the `groups` claim so Gitea can require it as well. Gitea
# does not do PKCE (Kanidm's own Gitea example turns it off), and short
# usernames keep Gitea accounts "kari", not "kari@id.vel...".
if [ -n "${GITEA_URL:-}" ] && [ -n "${RESPONSIBLE_GROUP:-}" ]; then
G=${GITEA_OAUTH2_CLIENT_ID:-prosjekt}
N=${GITEA_AUTH_NAME:-tomtervel}
has_client $G || $K system oauth2 create $G "${GITEA_LABEL:-Prosjekt}" "$GITEA_URL/user/login"
$K system oauth2 add-redirect-url $G "$GITEA_URL/user/oauth2/$N/callback" 2>/dev/null || true
$K system oauth2 update-scope-map $G "$RESPONSIBLE_GROUP" openid profile email >/dev/null
$K system oauth2 update-claim-map $G groups "$RESPONSIBLE_GROUP" "$RESPONSIBLE_GROUP" >/dev/null
$K system oauth2 update-claim-map-join $G groups array >/dev/null
$K system oauth2 warning-insecure-client-disable-pkce $G >/dev/null
$K system oauth2 prefer-short-username $G >/dev/null
gsecret=$($K system oauth2 show-basic-secret $G 2>/dev/null | tail -1)
discover="https://$ID_HOST/oauth2/openid/$G/.well-known/openid-configuration"
# On the host that runs that Gitea, add or update its source here;
# anywhere else, leave the secret in a file only this user can read.
# As root (this script is usually run under sudo) become the gitea
# user directly: on kasse root is not in sudoers.
as_gitea=""
if [ "$(id -u)" = 0 ]; then as_gitea="runuser -u gitea --"; elif sudo -n -u gitea true 2>/dev/null; then as_gitea="sudo -n -u gitea"; fi
if command -v gitea >/dev/null 2>&1 && [ -n "$as_gitea" ]; then
GT="$as_gitea gitea --config ${GITEA_CONFIG:-/etc/gitea/app.ini} admin auth"
id=$($GT list 2>/dev/null | awk -v n="$N" '$2 == n { print $1 }')
if [ -n "$id" ]; then
$GT update-oauth --id "$id" --key "$G" --secret "$gsecret" --auto-discover-url "$discover" \
--required-claim-name groups --required-claim-value "$RESPONSIBLE_GROUP" --scopes "openid profile email" >/dev/null
echo "Gitea sign-in source '$N' updated"
else
$GT add-oauth --name "$N" --provider openidConnect --key "$G" --secret "$gsecret" --auto-discover-url "$discover" \
--required-claim-name groups --required-claim-value "$RESPONSIBLE_GROUP" --scopes "openid profile email" >/dev/null
echo "Gitea sign-in source '$N' added: $GITEA_URL/user/login has a 'Sign in with $N' button"
fi
else
umask 077; printf '%s\n' "$gsecret" > gitea-oauth.secret
echo "note: no gitea CLI here - on the Gitea host, add the source with the secret in gitea-oauth.secret:"
echo " gitea admin auth add-oauth --name $N --provider openidConnect --key $G --secret \"\$(cat gitea-oauth.secret)\" \\"
echo " --auto-discover-url $discover --required-claim-name groups --required-claim-value $RESPONSIBLE_GROUP --scopes 'openid profile email'"
fi
fi
# The two secrets Kanidm makes, never printed: into portal.env so portal
# has them now, and into kanidm-setup.secrets for the repo's Actions
# secrets, which the next deploy writes portal.env from. The token is
# shown once, by Kanidm, at creation; a rerun keeps the one there is.
setenv() { if grep -q "^$1=" portal.env; then sed -i "s|^$1=.*|$1=$2|" portal.env; else printf '%s=%s\n' "$1" "$2" >> portal.env; fi; }
(umask 077; : > kanidm-setup.secrets)
secret=$($K system oauth2 show-basic-secret $C 2>/dev/null | tail -1)
setenv OAUTH2_CLIENT_SECRET "$secret"
printf 'OAUTH2_CLIENT_SECRET=%s\n' "$secret" >> kanidm-setup.secrets
if ! grep -q '^KANIDM_API_TOKEN=.' portal.env 2>/dev/null; then
token=$($K service-account api-token generate $SA "portal" --readwrite 2>/dev/null | tail -1)
if [ -n "$token" ]; then
setenv KANIDM_API_TOKEN "$token"
printf 'KANIDM_API_TOKEN=%s\n' "$token" >> kanidm-setup.secrets
echo "onboarding token written to portal.env"
else
echo "warning: could not generate the onboarding token - invites will fail closed until it is set" >&2
echo " retry by hand: $K service-account api-token generate $SA portal --readwrite" >&2
fi
fi
podman compose up -d portal
echo "portal restarted: signs in through $C, onboards through $SA, desks: $(echo $groups)"
echo
echo "Into the repo's Actions secrets, or the next deploy undoes them (from a"
echo "machine with gt; kanidm-setup.secrets is root's, here):"
echo " ssh kasse sudo cat $(pwd)/kanidm-setup.secrets | gt secret set -R tomtervel/infrastructure --env-file -"
echo "then remove it: sudo rm $(pwd)/kanidm-setup.secrets"
if [ -n "${SEED_ADMIN_EMAIL:-}" ]; then echo "the first person, $SEED_ADMIN_EMAIL, gets their invite from portal now (once)"; fi
echo
echo "Everyone after that is invited from a desk. By hand, if ever needed:"
echo " $K group add-members styret <person>"
-30
View File
@@ -1,30 +0,0 @@
# Kanidm server configuration. bootstrap.sh renders this into
# server.toml from .env; edit the template, not the rendered file.
# Reference: https://kanidm.github.io/kanidm/stable/server_configuration.html
version = "2"
bindaddress = "0.0.0.0:8443"
# Internal self-signed pair made by bootstrap.sh; Caddy terminates the
# public certificate and proxies here with verification disabled.
tls_chain = "/data/chain.pem"
tls_key = "/data/key.pem"
db_path = "/data/kanidm.db"
db_fs_type = "other"
db_arc_size = 2048
log_level = "info"
# domain must equal the DNS name Kanidm is served at.
domain = "${ID_HOST}"
origin = "https://${ID_HOST}"
# Trust X-Forwarded-For from Caddy on the compose network.
[http_client_address_info]
x-forward-for = ["172.16.0.0/12"]
[online_backup]
path = "/data/backups/"
schedule = "00 22 * * *"
versions = 7
+116
View File
@@ -0,0 +1,116 @@
# The move to portal 1.0
Portal 0.19 keeps the vel's records on NATS. Portal 1.0 keeps them in one
file of its own, and starts empty. This folder is what carries the records
across, on kasse, and the order the whole switch goes in.
| | |
|---|---|
| `move.sh rehearse` | the whole middle of the move beside the running site, into a volume it removes again |
| `move.sh move` | the same for real: stops the 0.19 site first, and fills `tomtervel_portal_data`, the volume the 1.0 stack starts on |
| `compare.py` | holds a 1.0 store to the export: every record, its state, its fields, its files, and the sign-ups in the order they came |
| `sink.py` | takes what the site would have sent while the sign-ups are taken again, and lets it go |
Everything is run as root on kasse. The export holds names and addresses:
it stays in `/srv/tomtervel/move-1.0` (root only) and nothing here prints
a name, an address or a text, only counts and the names of fields.
## What `move.sh` does
1. **Export** with portal 0.19.3 (`portal export`), reading NATS only.
2. **Rewrite** for the 1.0 content with `flytting/fra-0.19.py` from
tomtervel/questions: the committees become `gruppe` on each record.
3. **Import** with portal 1.0 into the volume, after a dry run.
4. **A 1.0 site on the store** that only kasse can reach (127.0.0.1:3997),
with the stack's garage for the files and no sign-in.
5. **The sign-ups** again, through their form
(`flytting/pameldinger.py`), in the order they came. A sign-up cannot
be imported: in 1.0 a seat is taken through the event's own count.
6. **Compare**, with every picture and document fetched as a visitor
would. Anything that differs is counted and the run ends non-zero.
7. **Stop** the site again.
### No mail leaves
Taking a sign-up again makes the mail the form makes ("Dere har plass"),
and what the site says in the chat's rooms. With no mail service beside
it, the site does not drop them: they wait in the store, and go out the
moment gdo dials it. A store filled on a preview and then started on in
production would mail every sign-up on its first start.
So while the site of step 4 runs, its `mail`, `rooms` and `answers`
outboxes are posted to `sink.py` (`DHD_HOOKS`), which acknowledges each
row and delivers nothing. The run says how many mails it took, and fails
if that is not one per sign-up. `payments` is left alone: nothing the
move does asks for money.
The cost: nobody gets a new link to withdraw by, and the links in the
mail 0.19 sent stop working at the move. Someone who cannot come tells
the board, who takes them off on the event's page.
## The switch, in order
Rehearsed on 2026-11-24 against the live site: 91 records and 15 sign-ups
(25 guests) across, all 53 files fetched, 15 mails taken by the sink,
nothing differing. The 1.0 stack was run the same day beside the live
one, with made-up records: mail out, a payment settled, content loaded,
and gdo and kron back after portal was restarted and made anew.
The site is down from step 4 until step 7 is done.
1. **Programs that dial a 1.0 site**: kron's image `0.3.0`, and a
commit of uhhm/gdo with its NATS mode gone, which the stack builds
gdo from. The chat does not come along: cnats speaks NATS only, and
kino has no image.
2. **Org secret `LOAD_TOKEN`** (`openssl rand -hex 24`, `gt secret set
LOAD_TOKEN -o tomtervel`), and this repo's variables `GDO_RELEASE`
(that commit), `KRON_RELEASE=0.3.0`, `COMPOSE_PROFILES=pay`.
3. **On kasse, the images the stack will run**, so the move can read
their keys: from a checkout of this branch, `podman build -t
localhost/tomtervel-gdo:<GDO_RELEASE> --build-arg
GDO_RELEASE=<GDO_RELEASE> gdo`, and `podman pull
project.uhhm.no/uhhm/kron:0.3.0`. And the new `deploy-tomtervel` in
`/usr/local/bin` (its first lines say how).
4. **`move.sh rehearse`** once more, then **`move.sh move`**, both with
`GDO_IMAGE` and `KRON_IMAGE` naming those images. `move` stops the
0.19 site, and ends with `DHD_KEYS` and `PORTAL_DHD`.
5. **Those two** as variables of this repo, and the org's
`PORTAL_RELEASE=v1.0.2`.
6. **The content**: questions#48 merged, so `main` is the 1.0 content.
Its reload fails, since the site is down; the site reads `main` as it
starts.
7. **The stack**: this merged, which deploys it. `podman stop
tomtervel-cnats-1` afterwards; `tomtervel-nats-1` is left running.
8. **Look**: `/hva-skjer` says 25 of 100 seats, a document opens, a
sign-in lands on `/styret` with its lists, the log says gdo and kron
are beside the site, and a test invite arrives.
9. **Rauthy's groups**: from `komiteer_<id>_medlem` and `_leder` to the
group named as its page (questions' README has the names).
### Going back
- **Before step 5**: `podman start tomtervel-portal-1`, and remove
`tomtervel_portal_data`. Nothing else was touched.
- **After**: the stack's merge and the content's reverted, the old
`deploy-tomtervel` installed, and the variables back to what they
were (`PORTAL_RELEASE=v0.19.2`, `GDO_RELEASE=v0.2.0`,
`KRON_RELEASE=0.1.0`, `COMPOSE_PROFILES=chat,pay`), then the deploy.
NATS still holds everything 0.19 had as long as `tomtervel_nats_data`
is kept, so keep it for some weeks. What people did on 1.0 in between
does not go back with it.
### What does not come across
- **Sign-ins.** Everyone signs in again. Their accounts and groups are in
Rauthy and are not touched.
- **Invites nobody has answered yet** stay valid in Rauthy, but the
site's list of them starts empty.
- **Each record's history.** A record arrives with one event saying it
was imported, and its date.
- **The chat,** and its history.
- **Payments under way in kron.** The new kron starts with none open: a
pay link mailed before the move no longer settles. A household that
owed its fee is marked paid by the treasurer when the money is seen,
or signs up again for a new link.
- **The site's backups** are off until `PORTAL_BACKUP_TO` is set
(README.md, "Backups").
+88
View File
@@ -0,0 +1,88 @@
# Compares a 1.0 store (read over /dhd/1/read) with the 0.19 export.
# Prints counts and field NAMES only: never a name, an address or a text.
#
# compare.py <site> <token file> <records-1.0.yaml> <places.yaml> [--files] [bucket ...]
#
# The token must be named `read` in the site's DHD_TOKENS. With buckets
# named, only those are held to the store; --files also fetches every
# file a record names, as a visitor would.
import json, sys, re, hashlib, urllib.request, urllib.error, yaml, collections
args = [a for a in sys.argv[1:] if not a.startswith('--')]
files = '--files' in sys.argv
site, tokfile, records, places = args[:4]
buckets = args[4:]
tok=open(tokfile).read().strip()
def read(bucket):
r=urllib.request.Request(site+'/dhd/1/read',data=json.dumps({'bucket':bucket}).encode(),
headers={'Authorization':'Bearer '+tok,'Content-Type':'application/json'})
return json.load(urllib.request.urlopen(r))
def h(s): return hashlib.sha256(str(s).encode()).hexdigest()[:8]
def norm(s): return re.sub(r'\s+',' ',re.sub(r'<[^>]+>',' ',str(s))).strip()
bad=0
y=yaml.safe_load(open(records))
for b,recs in y.items():
if buckets and b not in buckets: continue
if not isinstance(recs,list): print(f'{b}: not a list in the export, skipped'); continue
st=read(b); c=collections.Counter(); diff=collections.Counter(); kinds=collections.Counter()
ids={str(r['id']) for r in recs}
for r in recs:
s=st.get(str(r['id']))
if s is None: c['missing in store']+=1; continue
c['found']+=1
if r.get('state') and r['state']!=s['state']: c['state differs']+=1
at=r.get('at')
if at is not None:
got=(s.get('at') or {}).get('text','')
if not str(got).startswith(str(at)[:10]): c['at differs']+=1
f=r.get('fields') or {}; g=s.get('responses') or {}
for k,v in f.items():
if k not in g: diff[k+': not in store']+=1
elif str(g[k])==str(v): pass
elif norm(g[k])==norm(v): diff[k+': differs in markup or spacing only']+=1
else: diff[k+': DIFFERS']+=1
for k in g:
if k not in f and g[k] not in ('',None): diff[k+': in store only']+=1
for k in ('vedlegg','bilde'):
v=g.get(k)
if not v: continue
if not files: kinds[k+' named']+=1; continue
try:
with urllib.request.urlopen(f'{site}/attachment/{b}/{r["id"]}/{k}', timeout=30) as a:
kinds[f'{k} fetched' if len(a.read())>0 else f'{k} EMPTY']+=1
except urllib.error.HTTPError as e:
# a list that needs a sign-in keeps its files to those signed in
kinds[f'{k} needs a sign-in' if e.code in (401,403) else f'{k} FAILED {e.code}']+=1
extra=[k for k in st if k not in ids]
states=collections.Counter(s['state'] for s in st.values())
print(f'{b}: export {len(recs)}, store {len(st)}, {dict(c)}, extra in store {len(extra)}')
print(f' states in store {dict(states)}')
if diff: print(f' fields {dict(diff)}')
if kinds: print(f' files {dict(kinds)}')
bad+=c['missing in store']+c['state differs']+c['at differs']+len(extra)+sum(n for k,n in diff.items() if 'DIFFERS' in k or 'not in store' in k)
bad+=sum(n for k,n in kinds.items() if 'FAILED' in k or 'EMPTY' in k)
# the sign-ups
p=yaml.safe_load(open(places)); st=read('pameldinger'); led=read('portal_places')
for b,recs in p.items():
live=sorted([r for r in recs if r.get('state') in ('tatt','venter')], key=lambda r:str(r['at']))
print(f'{b}: export {len(recs)} ({dict(collections.Counter(r.get("state") for r in recs))}), store {len(st)} ({dict(collections.Counter(s["state"] for s in st.values()))})')
sig=lambda f:(str(f.get('arrangement')),h(str(f.get('email','')).lower()),h(f.get('navn')),str(f.get('antall') or 1))
want=collections.Counter(sig(r['fields']) for r in live); got=collections.Counter(sig(s['responses']) for s in st.values())
print(f' same people, events and numbers: {want==got} (only in export {sum((want-got).values())}, only in store {sum((got-want).values())})')
bad+=sum((want-got).values())+sum((got-want).values())
seats=lambda rs,key:sum(int(key(r).get('antall') or 1) for r in rs)
print(f' guests: export {seats(live,lambda r:r["fields"])}, store {seats(st.values(),lambda s:s["responses"])}')
# the state each has: a seat stays a seat, a place in line a place in line
wst=collections.Counter((sig(r['fields']),r['state']) for r in live)
gst=collections.Counter((sig(s['responses']),s['state']) for s in st.values())
print(f' same state each: {wst==gst}'); bad+= (wst!=gst)
# the order: the ledger's against the order they came in 0.19
for key,l in led.items():
for line in ('taken','waiting'):
ids=[e['id'] for e in l.get(line,[])]
order=[sig(st[i]['responses']) for i in ids if i in st]
wanted=[sig(r['fields']) for r in live if r['state']==('tatt' if line=='taken' else 'venter') and str(r['fields'].get('arrangement')) in key]
ok = order==wanted
print(f' ledger {h(key)} {line}: {len(ids)} entries, each a record: {len(order)==len(ids)}, in the order they came: {ok}')
bad+= (not ok) or len(order)!=len(ids)
dup=[k for k,n in got.items() if n>1]; print(f' taken twice: {len(dup)}'); bad+=len(dup)
print('OK' if not bad else f'{bad} THINGS TO LOOK AT'); sys.exit(1 if bad else 0)
+194
View File
@@ -0,0 +1,194 @@
#!/usr/bin/env bash
# The vel's records from portal 0.19 (NATS) into a 1.0 store, on kasse, as
# root. README.md beside this has the whole switch; this is its middle.
#
# move.sh rehearse beside the running site, into a throwaway volume
# move.sh move stops the 0.19 site first, and fills the volume the
# 1.0 stack starts on (tomtervel_portal_data)
#
# Either way it: exports with portal 0.19.3, rewrites for the 1.0 content
# (flytting/fra-0.19.py in the content repo), imports with 1.0, starts a
# 1.0 site on the store that only this host can reach, takes the sign-ups
# again through their form (flytting/pameldinger.py), holds the store to
# the export (compare.py) and stops the site again.
#
# No mail leaves: while that site runs, what it would send (the mail to
# each sign-up, what it says in the chat's rooms) is posted to sink.py,
# which counts it and lets it go. A store started on without that step
# mails every sign-up as soon as gdo dials it.
#
# The keys: the site and the programs beside it (gdo, kron) know each
# other by key. With GDO_IMAGE and KRON_IMAGE named (move needs both),
# each program is started once on its own volume to say its key, the
# site is started knowing them, and the run ends with the two values the
# deploy wants, DHD_KEYS and PORTAL_DHD. They are public keys.
#
# Nothing is printed that names anyone: counts, and the names of fields.
set -euo pipefail
umask 077
mode=${1:-}
case "$mode" in rehearse|move) ;; *) sed -n '2,20p' "$0" >&2; exit 2 ;; esac
here=$(dirname "$(readlink -f "$0")")
infra=/srv/tomtervel/infrastructure
base=/srv/tomtervel/move-1.0
release=${PORTAL_RELEASE:-v1.0.2}
image=localhost/tomtervel-portal:$release
branch=${CONTENT_BRANCH_1_0:-innhold-1-0} # the content the 1.0 site will run
repo=https://prosjekt.klingenbergbygg.no/tomtervel/questions
old=tomtervel-portal-1 # the 0.19 site
stage=tomtervel-move-stage
port=3997; sink_port=3996
export_sha=e417cbfddb7d3710a36c7b3b0b6a86ff1ed6d08dcffc66417760f9b20fbdfe4f # portal-x86_64-linux v0.19.3
dhd_port=4397 # where the site of this run listens for programs
gdo_image=${GDO_IMAGE:-}; kron_image=${KRON_IMAGE:-}
if [ "$mode" = move ]; then
volume=tomtervel_portal_data; gdo_volume=tomtervel_gdo_data; kron_volume=tomtervel_kron_data
[ -n "$gdo_image" ] && [ -n "$kron_image" ] || { echo "move needs GDO_IMAGE and KRON_IMAGE: the images the 1.0 stack will run" >&2; exit 1; }
else
volume=tomtervel-move-rehearsal; gdo_volume=$volume-gdo; kron_volume=$volume-kron
fi
for i in $gdo_image $kron_image; do podman image exists "$i" || { echo "no image $i" >&2; exit 1; }; done
work=$base/$mode-$(date +%Y%m%d-%H%M%S)
podman image exists "$image" || { echo "no image $image: build it first (README.md)" >&2; exit 1; }
if [ "$mode" = move ] && podman volume exists "$volume"; then
echo "the volume $volume is already there: a move was made, or begun. Look before removing it." >&2; exit 1
fi
podman rm -f "$stage" >/dev/null 2>&1 || true
for p in $port $sink_port; do
if (exec 3<>"/dev/tcp/127.0.0.1/$p") 2>/dev/null; then echo "something already answers on 127.0.0.1:$p" >&2; exit 1; fi
done
[ "$mode" = rehearse ] && podman volume rm -f "$volume" "$gdo_volume" "$kron_volume" >/dev/null 2>&1 || true
install -d -m 0700 "$base" "$work"
cd "$work"
sink=
cleanup() {
[ -n "$sink" ] && kill "$sink" 2>/dev/null || true
podman rm -f "$stage" >/dev/null 2>&1 || true
}
trap cleanup EXIT
step() { printf '\n== %s\n' "$*"; }
if [ "$mode" = move ]; then
step "stopping the 0.19 site, so nothing is answered after the export"
podman stop -t 30 "$old" >/dev/null
echo "to go back before the 1.0 stack is up: podman start $old"
fi
step "export from 0.19"
if [ ! -x "$base/portal" ]; then
curl -sfL -o "$base/portal.part" https://project.uhhm.no/uhhm/portal/releases/download/v0.19.3/portal-x86_64-linux
echo "$export_sha $base/portal.part" | sha256sum -c --quiet
chmod 0700 "$base/portal.part"; mv "$base/portal.part" "$base/portal"
fi
# The content the 0.19 site runs, to read its buckets by.
old_branch=$(grep -m1 '^CONTENT_BRANCH=' "$infra/portal.env" | cut -d= -f2-)
old_at=${CONTENT_AT_0_19:-$old_branch}
git clone --quiet "$repo" content-0.19
git -C content-0.19 checkout --quiet "$old_at"
echo "0.19 content: $(git -C content-0.19 rev-parse --short HEAD)"
url=$(grep -m1 '^NATS_URL=' "$infra/portal.env" | cut -d= -f2-)
url=${url/@nats:4222/@127.0.0.1:4223}
case "$url" in *@127.0.0.1:4223*) ;; *) echo "NATS_URL is not the expected shape" >&2; exit 1 ;; esac
pay=$(grep -m1 '^PAY_URL=' "$infra/portal.env" | cut -d= -f2- || true)
( cd content-0.19 && PAY_URL="$pay" NATS_URL="$url" SITE_NAME=tomtervel "$base/portal" export --path questions --out ../export ) \
| grep -vE '@|[0-9]{8}' || true
ls export
step "rewrite for the 1.0 content ($branch)"
git clone --quiet --depth 1 -b "$branch" "$repo" content
echo "1.0 content: $(git -C content rev-parse --short HEAD)"
python3 content/flytting/fra-0.19.py export/records.yaml records-1.0.yaml
chmod -R a+rX content; chmod 711 "$base" "$work"; chmod 644 records-1.0.yaml
step "import into $volume"
podman volume create "$volume" >/dev/null
run() { podman run --rm --user 0 -v "$volume:/data" -v "$work:/w:ro" -e PORTAL_STORE=/data/site.redb -e PAY_URL="$pay" "$image" "$@"; }
run /app/portal import --path /w/content/questions /w/records-1.0.yaml --dry-run | tail -3
run /app/portal import --path /w/content/questions /w/records-1.0.yaml | tail -1
chmod 600 records-1.0.yaml; chmod 700 "$base"
dhd_keys=
if [ -n "$gdo_image" ] && [ -n "$kron_image" ]; then
step "the programs' keys"
# Each says its key before it dials, so a site that is not there will
# do. kron's ledger is kept out of it: only its key is made here.
nowhere=$(printf 'a%.0s' $(seq 64))@127.0.0.1:9
said() { sed 's/\x1b\[[0-9;]*m//g' | grep -o 'DHD_KEYS as [0-9a-f]\{64\}=[a-z,:]*' | head -1 | cut -d' ' -f3; }
gdo_key=$(podman run --rm --timeout 20 -v "$gdo_volume:/var/lib/gdo" -e GDO_KEY=/var/lib/gdo/gdo.key \
-e PORTAL_DHD="$nowhere" -e SMTP_HOST=127.0.0.1 -e SMTP_PORT=9 "$gdo_image" 2>&1 | said || true)
kron_key=$(podman run --rm --timeout 20 -v "$kron_volume:/var/lib/kron" -e KRON_KEY=/var/lib/kron/kron.key -e KRON_STATE=/tmp/none.redb \
-e PORTAL_DHD="$nowhere" -e SITE_NAME=tomtervel -e PROVIDER=fake -e PUBLIC_URL=http://127.0.0.1 -e LISTEN_ADDR=127.0.0.1:0 "$kron_image" 2>&1 | said || true)
[ -n "$gdo_key" ] && [ -n "$kron_key" ] || { echo "a program did not say its key (gdo: ${gdo_key:-nothing}, kron: ${kron_key:-nothing})" >&2; exit 1; }
dhd_keys="$gdo_key;$kron_key"
echo "$dhd_keys"
fi
step "a 1.0 site on the store, for this host only, its outboxes posted to the sink"
token=$(head -c 32 /dev/urandom | base64 | tr -dc A-Za-z0-9); printf %s "$token" > token
hash=$(printf %s "$token" | sha256sum | cut -d' ' -f1)
python3 "$here/sink.py" "$sink_port" > sink.out 2>&1 & sink=$!
# The files are in the stack's garage, which answers on the compose
# network only; the host reaches its address there. Compose doubles each
# "$" in an env file, podman does not.
grep -E '^GARAGE_' "$infra/portal.env" | sed 's/\$\$/$/g' > stage.env
garage=$(podman inspect tomtervel-garage-1 --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')
podman run -d --name "$stage" --user 0 --network host --add-host "garage:$garage" --env-file stage.env \
-v "$volume:/data" -v "$work/content:/w:ro" \
-e CONTENT_DIR=/w -e PORTAL_STORE=/data/site.redb -e SITE_NAME=tomtervel -e PUBLIC_URL="https://$(grep -m1 '^PORTAL_HOST=' "$infra/.env" | cut -d= -f2-)" \
-e LEPTOS_SITE_ADDR=127.0.0.1:$port -e LEPTOS_SITE_ROOT=site -e LEPTOS_HASH_FILES=true -e PAY_URL="$pay" \
-e DHD_TOKENS="$hash=submit:pameldinger,read" -e DHD_HOOK_SECRET="$token" \
-e DHD_KEYS="$dhd_keys" -e DHD_BIND="127.0.0.1:$dhd_port" \
-e DHD_HOOKS="mail=http://127.0.0.1:$sink_port/;rooms=http://127.0.0.1:$sink_port/;answers=http://127.0.0.1:$sink_port/" \
"$image" >/dev/null
code=000
for _ in $(seq 1 45); do
code=$(curl -s -o /dev/null -w '%{http_code}' "http://127.0.0.1:$port/" || true)
[ "$code" = 200 ] && break; sleep 1
done
[ "$code" = 200 ] || { echo "the site did not come up ($code)" >&2; podman logs "$stage" 2>&1 | tail -20 >&2; exit 1; }
step "the sign-ups, through their form, in the order they came"
SUBMIT_TOKEN=$token python3 content/flytting/pameldinger.py export/places.yaml "http://127.0.0.1:$port" --send \
| sed -E 's/ på [0-9a-f]+,/,/' | tee replay.out | tail -3
sent=$(grep -c '^sendt' replay.out || true)
step "the store against the export"
ok=0
python3 "$here/compare.py" "http://127.0.0.1:$port" token records-1.0.yaml export/places.yaml --files || ok=1
step "what the site would have sent, taken by the sink"
# A hook looks every 10 seconds; wait until the mail is all there and nothing more comes.
for _ in $(seq 1 12); do sleep 10; kill -USR1 "$sink"; sleep 1; [ "$(tail -1 sink.out | cut -d' ' -f2)" = "$sent" ] && break; done
sleep 15
podman stop -t 30 "$stage" >/dev/null
kill "$sink"; wait "$sink" 2>/dev/null || true; sink=
grep -v '^count ' sink.out
mails=$(grep -m1 '^mail: ' sink.out | sed -E 's/^mail: ([0-9]+) rows.*/\1/' || true)
if [ "${mails:-0}" != "$sent" ]; then echo "MAIL: $sent sign-ups sent, ${mails:-0} mails taken by the sink"; ok=1; fi
podman logs "$stage" 2>&1 | sed 's/\x1b\[[0-9;]*m//g' | grep -E ' (WARN|ERROR) ' | grep -v '@' > site-warnings.out || true
echo "warnings and errors in the site's log: $(wc -l < site-warnings.out)"
cut -d' ' -f2- site-warnings.out | cut -c1-200 | sort | uniq -c | head -15
site_key=$(podman logs "$stage" 2>&1 | sed 's/\x1b\[[0-9;]*m//g' | grep 'programs dial this site here' | grep -o 'key=[0-9a-f]\{64\}' | head -1 | cut -d= -f2 || true)
run chown -R portal /data
podman rm -f "$stage" >/dev/null
if [ -n "$dhd_keys" ]; then
step "what the deploy wants (Actions variables of this repo; public keys)"
[ -n "$site_key" ] || { echo "the site did not say its key" >&2; ok=1; }
printf 'DHD_KEYS=%s\nPORTAL_DHD=%s@127.0.0.1:4300\n' "$dhd_keys" "$site_key" | tee keys.env
fi
step "done"
if [ "$mode" = rehearse ]; then
podman volume rm -f "$volume" "$gdo_volume" "$kron_volume" >/dev/null
echo "rehearsal volume removed; the export and the logs are in $work (root only)"
else
echo "the 1.0 store is in $volume; the export is in $work (root only)"
if [ "$ok" = 0 ]; then echo "next: the 1.0 stack on it (README.md, step 5)"; else echo "not as it should be: podman start $old brings the 0.19 site back; remove $volume before trying again"; fi
fi
exit "$ok"
+27
View File
@@ -0,0 +1,27 @@
# Takes what a 1.0 site posts from its outboxes (DHD_HOOKS) and lets each row go:
# sink.py <port> on 127.0.0.1; SIGUSR1 prints `count <mail rows so far>`, SIGTERM the sums.
# Nothing is delivered and nothing kept: it counts rows per outbox, and for
# mail how many addresses and which subjects. Never an address or a body.
import sys, json, hashlib, collections, http.server, signal
port=int(sys.argv[1]); rows=collections.Counter(); who=collections.defaultdict(set); subj=collections.Counter(); keys=collections.defaultdict(set)
class H(http.server.BaseHTTPRequestHandler):
def do_POST(s):
b=s.rfile.read(int(s.headers.get('Content-Length',0))); o=s.headers.get('Dhd-Outbox','?'); rows[o]+=1
try:
d=json.loads(b); keys[o].update(d.keys())
if o=='mail':
to=d.get('to'); to=to if isinstance(to,list) else [to]
for t in to: who[o].add(hashlib.sha256(str(t).encode()).hexdigest())
subj[str(d.get('subject'))[:60]]+=1
except Exception: pass
s.send_response(204); s.end_headers()
def log_message(s,*a): pass
def done(*a):
print(f'mail: {rows["mail"]} rows to {len(who["mail"])} different addresses; subjects {dict(subj)}')
for o,n in rows.items():
if o!='mail': print(f'{o}: {n} rows; fields {sorted(keys[o])}')
sys.stdout.flush(); sys.exit(0)
def count(*a): print('count',rows['mail']); sys.stdout.flush()
signal.signal(signal.SIGUSR1,count)
signal.signal(signal.SIGTERM,done); signal.signal(signal.SIGINT,done)
http.server.HTTPServer(('127.0.0.1',port),H).serve_forever()
+8 -3
View File
@@ -12,16 +12,21 @@
# reason.
FROM archlinux:base
ARG PORTAL_RELEASE
RUN pacman -Sy --noconfirm --needed ca-certificates curl \
# -Syu, never -Sy: a partial upgrade pulls a library newer than what the
# base image's own pacman was built against (openssl 4, November 2026) and
# refuses to install.
RUN pacman -Syu --noconfirm --needed ca-certificates curl \
&& pacman -Scc --noconfirm \
&& rm -rf /var/cache/pacman/pkg/* /var/lib/pacman/sync/*
WORKDIR /app
RUN curl -sfL "https://project.uhhm.no/uhhm/portal/releases/download/${PORTAL_RELEASE}/portal-${PORTAL_RELEASE}.tar.gz" \
| tar -xz -C /app \
&& test -x /app/portal
# A non-root user; the image ships nothing writable it needs.
# A non-root user. What it writes is in two volumes: the search cache,
# and /data, where the site's store is (PORTAL_STORE in compose.yml); a
# new volume takes this directory's owner.
RUN useradd --system --no-create-home portal
RUN mkdir -p /app/learn-cache && chown portal /app/learn-cache
RUN mkdir -p /app/learn-cache /data && chown portal /app/learn-cache /data
USER portal
EXPOSE 3000
CMD ["/app/portal"]
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
# The sign-in providers Rauthy offers beside its own accounts, as the
# deploy keeps them: today Vipps Login. Rauthy has no file for this, only
# its API, so this script is the file: run on every deploy, it makes the
# provider the first time and updates it after, by name, so a change here
# is a change in Rauthy. Needs RAUTHY_HOST, RAUTHY_API_KEY (AuthProviders
# read/create/update), VIPPS_LOGIN_CLIENT_ID and VIPPS_LOGIN_CLIENT_SECRET;
# with any of them unset it changes nothing and says so.
#
# Vipps's side: the sales unit's Vipps Login must have the redirect URI
# https://<RAUTHY_HOST>/auth/v1/providers/callback registered, or every
# sign-in is refused there.
#
# auto_link: a Vipps sign-in whose (Vipps-verified) email is an account
# here already is linked to that account, so the board's password and
# passkey accounts and Vipps lead to the same person and the same groups.
# Without it Rauthy refuses the sign-in and asks them to link it from
# their account page first, which nobody finds. auto_onboarding: a new
# address becomes an account on the spot.
set -euo pipefail
for v in RAUTHY_HOST RAUTHY_API_KEY VIPPS_LOGIN_CLIENT_ID VIPPS_LOGIN_CLIENT_SECRET; do
[ -n "${!v:-}" ] || { echo "rauthy-providers: $v is not set; nothing changed"; exit 0; }
done
base="https://$RAUTHY_HOST/auth/v1"
auth="Authorization: API-Key $RAUTHY_API_KEY"
vipps=$(jq -n --arg id "$VIPPS_LOGIN_CLIENT_ID" --arg secret "$VIPPS_LOGIN_CLIENT_SECRET" '{
name: "Vipps", typ: "custom", enabled: true,
issuer: "https://api.vipps.no/access-management-1.0/access/",
authorization_endpoint: "https://api.vipps.no/access-management-1.0/access/oauth2/auth",
token_endpoint: "https://api.vipps.no/access-management-1.0/access/oauth2/token",
userinfo_endpoint: "https://api.vipps.no/vipps-userinfo-api/userinfo",
jwks_endpoint: "https://api.vipps.no/access-management-1.0/access/.well-known/jwks.json",
client_id: $id, client_secret: $secret, client_secret_basic: true, client_secret_post: false,
scope: "openid name email phoneNumber", use_pkce: true, danger_allow_insecure: false, root_pem: null,
admin_claim_path: null, admin_claim_value: null, mfa_claim_path: null, mfa_claim_value: null,
auto_onboarding: true, auto_link: true }')
# Listing is a POST in Rauthy's API.
existing=$(curl -sf -X POST -H "$auth" -H 'content-type: application/json' -d '{}' "$base/providers" | jq -r '.[] | select(.name == "Vipps") | .id' | head -n1)
if [ -n "$existing" ]; then
curl -sf -X PUT -H "$auth" -H 'content-type: application/json' -d "$vipps" "$base/providers/$existing" >/dev/null
echo "rauthy-providers: Vipps updated ($existing)"
else
id=$(curl -sf -X POST -H "$auth" -H 'content-type: application/json' -d "$vipps" "$base/providers/create" | jq -r .id)
echo "rauthy-providers: Vipps made ($id)"
fi
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# Tomter Vel's colours on Rauthy's pages (sign-in, account, the admin),
# as the deploy keeps them: Rauthy has no file for a theme, only its API,
# so this script is the file. The palette is the site's (custom.css in
# tomtervel/questions): accent #1785c2, paper #fffceb, ink #111111, line
# #e6dfbf, error #ff4136, as HSL. Rauthy themes per OIDC client; the
# sign-in page shows the client's theme and the account pages Rauthy's
# own (`rauthy`), so both get the same. Needs RAUTHY_HOST and
# RAUTHY_API_KEY with Clients read and update; without those rights it
# says so and changes nothing.
set -euo pipefail
for v in RAUTHY_HOST RAUTHY_API_KEY; do
[ -n "${!v:-}" ] || { echo "rauthy-theme: $v is not set; nothing changed"; exit 0; }
done
base="https://$RAUTHY_HOST/auth/v1"
auth="Authorization: API-Key $RAUTHY_API_KEY"
# Light: paper and ink. Dark: the same blue on a night sky.
theme=$(jq -n '{
light: { text: [46, 15, 27], text_high: [0, 0, 7], bg: [51, 100, 96], bg_high: [49, 44, 90],
action: [201, 79, 43], accent: [201, 79, 33], error: [3, 100, 61],
btn_text: "white", theme_sun: "hsla(var(--action) / .7)", theme_moon: "hsla(var(--accent) / .85)" },
dark: { text: [49, 30, 78], text_high: [51, 100, 96], bg: [201, 35, 9], bg_high: [201, 25, 16],
action: [201, 79, 52], accent: [201, 70, 70], error: [3, 100, 61],
btn_text: "hsl(var(--bg))", theme_sun: "hsla(var(--action) / .7)", theme_moon: "hsla(var(--accent) / .85)" },
border_radius: "6px" }')
for client in rauthy ${OAUTH2_CLIENT_ID:-portal} ${CHAT_OAUTH2_CLIENT_ID:-}; do
body=$(jq --arg c "$client" '. + {client_id: $c}' <<<"$theme")
code=$(curl -s -o /tmp/rauthy-theme.out -w '%{http_code}' -X PUT -H "$auth" -H 'Content-Type: application/json' -d "$body" "$base/theme/$client")
case "$code" in
200|201|204) echo "rauthy-theme: $client themed" ;;
403) echo "rauthy-theme: the API key may not update clients (403); give it Clients read+update, or set the theme in the admin. Nothing changed."; exit 0 ;;
*) echo "rauthy-theme: $client: http $code: $(head -c 300 /tmp/rauthy-theme.out)"; exit 1 ;;
esac
done
+37
View File
@@ -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"]
+53
View File
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# Vipps's webhooks for the money service (kron): registers kron's
# endpoint with the Webhooks API for the Medlemskap sales unit, or lists
# what is registered. Run by a person with the keys in `pass`, not by the
# deploy: the registration answers with the webhook's secret exactly once,
# and that secret has to become the repo secret VIPPS_WEBHOOK_SECRET (and
# kron's WEBHOOK_SECRET) without ever being printed in a public log.
#
# ./vipps-webhook.sh list # what Vipps has for the unit
# ./vipps-webhook.sh register # kron's /webhook, secret into pass
# ./vipps-webhook.sh delete <webhook id>
#
# VIPPS_ENV=test uses apitest.vipps.no and the test unit's keys
# (tomtervel/vipps/medlemskap-test in pass); the default is production
# (tomtervel/vipps/medlemskap). PAY_HOST is the host kron answers on
# (betaling.tomtervel.no).
set -euo pipefail
env=${VIPPS_ENV:-prod}
case "$env" in
test) api=https://apitest.vipps.no; entry=tomtervel/vipps/medlemskap-test ;;
prod) api=https://api.vipps.no; entry=tomtervel/vipps/medlemskap ;;
*) echo "VIPPS_ENV is $env; it is test or prod" >&2; exit 2 ;;
esac
host=${PAY_HOST:-betaling.tomtervel.no}
field() { pass show "$entry" | sed -n "s/^$1: //p" | head -n1; }
msn=$(field msn); cid=$(field client_id); csec=$(field client_secret); sub=$(field subscription_key_primary)
[ -n "$msn" ] && [ -n "$cid" ] && [ -n "$csec" ] && [ -n "$sub" ] || { echo "pass entry $entry lacks msn, client_id, client_secret or subscription_key_primary" >&2; exit 1; }
token=$(curl -sf -X POST "$api/accesstoken/get" -H "client_id: $cid" -H "client_secret: $csec" \
-H "Ocp-Apim-Subscription-Key: $sub" -H "Merchant-Serial-Number: $msn" -H 'Content-Length: 0' | jq -r .access_token)
[ -n "$token" ] && [ "$token" != null ] || { echo "no access token from $api" >&2; exit 1; }
auth=(-H "Authorization: Bearer $token" -H "Ocp-Apim-Subscription-Key: $sub" -H "Merchant-Serial-Number: $msn" -H 'Content-Type: application/json')
case "${1:-list}" in
list)
curl -sf "$api/webhooks/v1/webhooks" "${auth[@]}" | jq .
;;
register)
url="https://$host/webhook"
events='["epayments.payment.created.v1","epayments.payment.authorized.v1","epayments.payment.captured.v1","epayments.payment.aborted.v1","epayments.payment.expired.v1","epayments.payment.cancelled.v1","epayments.payment.terminated.v1","epayments.payment.refunded.v1"]'
answer=$(curl -sf -X POST "$api/webhooks/v1/webhooks" "${auth[@]}" -d "$(jq -n --arg url "$url" --argjson events "$events" '{url: $url, events: $events}')")
id=$(jq -r .id <<<"$answer"); secret=$(jq -r .secret <<<"$answer")
[ -n "$secret" ] && [ "$secret" != null ] || { echo "Vipps answered without a secret: $(jq -c 'del(.secret)' <<<"$answer")" >&2; exit 1; }
# The secret goes into pass and nowhere on screen.
printf 'id: %s\nurl: %s\nsecret: %s\n' "$id" "$url" "$secret" | pass insert -m -f "$entry-webhook" >/dev/null
echo "registered webhook $id for $url; its secret is in pass as $entry-webhook"
echo "now: pass show $entry-webhook | sed -n 's/^secret: //p' | gt secret set VIPPS_WEBHOOK_SECRET"
;;
delete)
[ -n "${2:-}" ] || { echo "which webhook? ./vipps-webhook.sh delete <id>" >&2; exit 2; }
curl -sf -X DELETE "$api/webhooks/v1/webhooks/$2" "${auth[@]}" && echo "deleted $2"
;;
*) echo "usage: $0 list | register | delete <id>" >&2; exit 2 ;;
esac