19 Commits
Author SHA1 Message Date
bl 6cbd6ada9b Merge branch 'main' into kron-pay 2026-11-10 22:05:04 +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
11 changed files with 374 additions and 10 deletions

No files matched your search

+59
View File
@@ -19,6 +19,8 @@ on:
- Caddyfile
- portal/**
- gdo/**
- rauthy-providers.sh
- rauthy-theme.sh
- nats/nats.conf
- rauthy/config.toml
- deploy-tomtervel
@@ -34,6 +36,7 @@ jobs:
# What the stack is.
PORTAL_HOST: ${{ vars.PORTAL_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 }}
@@ -76,6 +79,15 @@ jobs:
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. All five are needed
# once COMPOSE_PROFILES has `pay`; 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:
# A missing value stops here, by name, before anything on the host
# is touched. Only names are printed: the log is public.
@@ -92,6 +104,14 @@ jobs:
[ -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"
@@ -104,6 +124,7 @@ jobs:
CNATS_TAG=$CNATS_TAG
KRON_RELEASE=$KRON_RELEASE
COMPOSE_PROFILES=$COMPOSE_PROFILES
PAY_HOST=$PAY_HOST
RAUTHY_HOST=$RAUTHY_HOST
OIDC_ISSUER=$OIDC_ISSUER
EOF
@@ -133,6 +154,13 @@ jobs:
RAUTHY_API_KEY=$RAUTHY_API_KEY
RAUTHY_LANGUAGE=$RAUTHY_LANGUAGE
EOF
# With the money service in the stack, portal may ask for
# payments without `by_hand`; the address itself is never
# called (the two talk over NATS), 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://kron:3000" >> "$STAGE/portal.env"
fi
# NATS itself (nats.conf reads NATS_PASSWORD), gdo and the chat.
cat > "$STAGE/nats.env" <<EOF
NATS_PASSWORD=$NATS_PASSWORD
@@ -142,6 +170,15 @@ jobs:
OAUTH2_CLIENT_ID=$CHAT_OAUTH2_CLIENT_ID
OAUTH2_CLIENT_SECRET=$CHAT_OAUTH2_CLIENT_SECRET
EOF
# kron: Vipps's keys for the Medlemskap sales unit. Written even
# without the profile, so the file compose names is there.
cat > "$STAGE/kron.env" <<EOF
VIPPS_MSN=$VIPPS_MSN
VIPPS_CLIENT_ID=$VIPPS_CLIENT_ID
VIPPS_CLIENT_SECRET=$VIPPS_CLIENT_SECRET
VIPPS_SUBSCRIPTION_KEY=$VIPPS_SUBSCRIPTION_KEY
WEBHOOK_SECRET=$VIPPS_WEBHOOK_SECRET
EOF
# Rauthy's secrets. The first admin is the vel's first person.
cat > "$STAGE/rauthy.env" <<EOF
ENC_KEYS=$RAUTHY_ENC_KEY
@@ -156,6 +193,28 @@ jobs:
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/nats.env" "$STAGE/chat.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
+1
View File
@@ -5,3 +5,4 @@ gitea-oauth.secret
dns/cloudflare.env
nats.env
rauthy.env
kron.env
+97 -8
View File
@@ -62,10 +62,13 @@ account mail, in Norwegian. Portal and the chat sign in there
`responsible` gets an account at start and a place in
`RESPONSIBLE_GROUP` (`redaktor`).
The groups are portal's (`PEOPLE_BACKEND=memberships`): 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.
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
@@ -103,7 +106,7 @@ Run workflow**. Set them with `gt` (`gt variable set NAME --body ...`,
| `COMPOSE_PROFILES` | variable | repo | `chat` |
| `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` |
| `PEOPLE_BACKEND`, `RESPONSIBLE_GROUP` | variable | repo | `rauthy`, `redaktor` |
| `OAUTH2_CLIENT_ID`, `CHAT_OAUTH2_CLIENT_ID` | variable | repo | the Rauthy clients of the site and the chat: `portal`, `chat` |
| `NATS_ADOPT_LEGACY` | variable | repo | `sole` |
| `GARAGE_S3_ENDPOINT`, `GARAGE_UPLOADS_BUCKET` | variable | repo | uploads |
@@ -120,6 +123,11 @@ Run workflow**. Set them with `gt` (`gt variable set NAME --body ...`,
| `OIDC_ISSUER` | variable | repo | where the site and the chat sign 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 |
| `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.
@@ -127,6 +135,54 @@ 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: 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=chat,pay`). Portal
decides when money is owed: a household entering `open` or `fornyes` in
the content's aggregates owes the fee, and portal publishes one request
on this stack's NATS. kron answers at once 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 says `paid`
on the bus; portal moves the household to `betalt`, grants `medlemmer`,
and mails them. Vipps's keys live in `kron.env` and nowhere else; portal
never calls Vipps. `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`, `VIPPS_MSN` and the three key secrets (table above).
The keys are in `pass` as `tomtervel/vipps/medlemskap`.
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=chat,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`
@@ -152,16 +208,49 @@ On a new host:
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`, redirect
`https://tomtervel.no/auth/callback`) and `chat` (also
`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 and groups into `RAUTHY_API_KEY`.
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
- Rauthy's database is the `rauthy_data` volume: the accounts, passkeys
+31
View File
@@ -87,6 +87,9 @@ services:
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).
@@ -141,6 +144,34 @@ services:
nats:
condition: service_healthy
# The money service (uhhm/kron): portal asks for a payment on this
# NATS as a household owes its fee, kron gives it a link to pay by,
# talks to Vipps's ePayment API for the Medlemskap sales unit, and
# says `paid` back on the same bus. Vipps's keys are in kron.env and
# nowhere else; portal never calls Vipps. Host-published for kasse's
# host Caddy (betaling.tomtervel.no -> here): the pay links, the page
# people come back to from Vipps, and Vipps's webhooks. A profile, since
# it needs kron.env: COMPOSE_PROFILES gains `pay` once the keys are set.
kron:
profiles: ["pay"]
image: project.uhhm.no/uhhm/kron:${KRON_RELEASE:-no-tag-set}
restart: unless-stopped
env_file:
- nats.env
- kron.env
environment:
# Must be the portal's own: a request names its site.
SITE_NAME: tomtervel
PROVIDER: vipps
VIPPS_ENV: prod
PUBLIC_URL: https://${PAY_HOST:-no-host-set}
LISTEN_ADDR: 0.0.0.0:3000
ports:
- "127.0.0.1:3080:3000"
depends_on:
nats:
condition: service_healthy
# 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
+8
View File
@@ -31,11 +31,19 @@ D("tomtervel.no", REG_NONE, DnsProvider(DSP_CLOUDFLARE),
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
+1 -1
View File
@@ -25,7 +25,7 @@ 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 \
&& pacman -Scc --noconfirm \
&& rm -rf /var/cache/pacman/pkg/* /var/lib/pacman/sync/*
+41
View File
@@ -32,3 +32,44 @@ chat.tomtervel.no {
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
}
+4 -1
View File
@@ -12,7 +12,10 @@
# 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
+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
+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