13 Commits
Author SHA1 Message Date
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
blandClaude Opus 5.5 7c0c244ade DNS: kasse's DKIM key for tomtervel.no
dns / dns (push) Successful in 5s
Made on kasse by kasse-dkim-tomtervel.sh (selector kasse); rspamd signs
mail From @tomtervel.no with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-07 16:58:02 +01:00
blandClaude Opus 5.5 26ccd0430d PORTAL_RELEASE is the org's variable, shared with the content lint
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-07 16:54:05 +01:00
blandClaude Opus 5.5 38e209ca4f DNS: the old website at gammel.tomtervel.no, no web.
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-07 16:51:48 +01:00
bl 6e424e6618 Merge pull request 'Alt i Actions-variabler og -hemmeligheter, og tomtervel.no sin DNS' (#1) from rollout into main
deploy / deploy (push) Successful in 27s
dns / dns (push) Successful in 4s
Reviewed-on: #1
2026-11-07 16:49:17 +01:00
blandClaude Opus 5.5 3bcd2bc68c Every value in Gitea's Actions variables and secrets
dns / dns (push) Successful in 11s
The stack's settings are repo variables, its secrets repo secrets, and
NATS_PASSWORD an org secret the content repo can share. The deploy
workflow checks they are all set, writes .env, portal.env, nats.env and
chat.env into the runner's own directory, and the root script (now in
the repo as deploy-tomtervel) pulls main, puts them in place as root's
and brings the stack up. So nothing is edited on the host or committed:
a host name or a version is a variable changed and a Run workflow.

nats.conf reads NATS_PASSWORD from its environment, so it is committed
rather than rendered. bootstrap.sh only makes Kanidm's config and
certificate and recovers its admins; kanidm-setup.sh reads portal.env,
and leaves the two secrets it makes in kanidm-setup.secrets for gt.

The DNS workflow uses actions/checkout and actions/cache (the runner's
cache server) for dnscontrol, at the DNSCONTROL_VERSION variable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-07 16:44:51 +01:00
blandClaude Opus 5.5 efdae35d15 DNS workflow: dnscontrol in the runner user's cache
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-07 16:30:40 +01:00
blandClaude Opus 5.5 e183510466 DNS from CI: preview on every push, applied by hand on main
dns / dns (push) Failing after 5s
dns.yml runs DNSControl on kasse's host runner with the repo secret
CLOUDFLARE_API_TOKEN: check and preview on any push touching dns/,
push only from Run workflow on main, so a merge is never the cutover.
Push events only; the repo is public.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-07 16:29:56 +01:00
blandClaude Opus 5.5 a76e6321ee What the stack is, in git: .env committed, the secrets on the host
.env is what `podman compose` reads as is: the hosts, the versions and
where the content comes from, so moving to tomtervel.no or bumping portal
is a commit that the deploy workflow brings up. Nothing in it is secret.

The secrets stay on kasse in secrets.env (the old .env's NATS password,
OAuth2 secret and first person), and what the scripts render from it.
gdo and the chat get NATS_URL from nats.env instead of interpolating
the password, and portal takes its URLs and content settings from .env
over portal.env, so a new host name reaches it without re-running
bootstrap.sh. The deploy script on kasse is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L5fbDmSQSb6u27EiEuwzoM
2026-11-07 16:29:55 +01:00
14 changed files with 556 additions and 147 deletions

No files matched your search

-65
View File
@@ -1,65 +0,0 @@
# Copy to .env and fill in. Everything rendered from this (nats.conf,
# kanidm/server.toml, portal.env) is gitignored.
# Where the site and the identity provider are served. Both need an A
# record pointing at this host before the first start (Caddy gets the
# certificates over HTTP-01). tomtervel.no itself stays where it is
# until the vel decides to point the apex here.
PORTAL_HOST=vel.klingenbergbygg.no
ID_HOST=id.vel.klingenbergbygg.no
# The portal version to run: a tag of https://project.uhhm.no/uhhm/portal
PORTAL_RELEASE=v0.10.2
# The content this instance serves, and reloads live on every push.
CONTENT_REPO=https://prosjekt.klingenbergbygg.no/tomtervel/questions
CONTENT_BRANCH=main
SITE_NAME=tomtervel
# Generated once by bootstrap.sh if left empty.
NATS_PASSWORD=
# The first person in: portal invites this address into the site's most
# privileged group (the board, on the vel - the group whose desk may
# invite into the most groups) and mails them the one-time link, once.
# Everyone else they invite themselves, from their desk.
SEED_ADMIN_EMAIL=
SEED_ADMIN_NAME=
# The people who ask the questions: everyone a page names as
# responsible gets an account (portal makes it at start and mails them)
# and joins this group. Kanidm names are ASCII: redaktor, "Redaktør".
RESPONSIBLE_GROUP=redaktor
# Where the groups live. `memberships`: portal keeps them itself, a person
# is their phone number first, and Kanidm only makes the account (until a
# sign-in everyone already has, like Vipps, takes over). Unset: Kanidm
# holds the groups too.
PEOPLE_BACKEND=memberships
# A project Gitea they may sign in to with the same account: kanidm-setup
# makes its OAuth2 client (only RESPONSIBLE_GROUP may use it) and, on the
# host that runs that Gitea, adds the sign-in source. Empty: no Gitea.
GITEA_URL=https://prosjekt.klingenbergbygg.no
GITEA_AUTH_NAME=tomtervel
# The vel's conversations, on their own address. go-live.sh sets the two
# below once chat.env (the sign-in client's secret, gitignored) is there;
# without them `up` leaves the chat out. 0.4.0 and older say the wrong
# name on their sign-in page: use a tag above it.
#CNATS_TAG=0.4.1
#COMPOSE_PROFILES=chat
CHAT_HOST=chat.vel.klingenbergbygg.no
# Filled in by bootstrap.sh after it creates the Kanidm client.
OAUTH2_CLIENT_ID=tomtervel-portal
OAUTH2_CLIENT_SECRET=
# Only for the optional runner profile: a registration token from
# prosjekt.klingenbergbygg.no -> tomtervel org -> Settings -> Actions -> Runners.
RUNNER_REGISTRATION_TOKEN=
# The gdo version to run: a tag of https://project.uhhm.no/uhhm/gdo,
# installed from the [uhhm] Arch registry. gdo hands the vel's mail to
# the host's mail server; on kasse that is Klingenberg Bygg's postfix.
GDO_RELEASE=v0.2.0
+144 -10
View File
@@ -1,13 +1,15 @@
# Deploy this stack onto the host it runs on. A push that changes the
# compose file, a Dockerfile or a rendered config pulls and brings the
# stack up; a portal or gdo upgrade is a commit that bumps the version in
# .env.example and, on the host, in .env.
# Deploy this stack onto kasse. Every value the stack runs with is an
# 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
# 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.
#
# Runs on kasse's host runner. It is not root: it may run one script,
# /usr/local/bin/deploy-tomtervel, which pulls this repo under
# /srv/tomtervel and runs `podman compose up -d --build` and nothing
# else. The .env on the host - the NATS password, the OAuth2 secret, the
# Kanidm token - is never in this repo and is not touched by a deploy.
# Runs on kasse's host runner, which is not root. It writes the env files
# into its own directory, and may run one script as root,
# /usr/local/bin/deploy-tomtervel (deploy-tomtervel here), which pulls
# main, puts those files in place and runs `podman compose up -d --build`.
name: deploy
on:
push:
@@ -17,14 +19,146 @@ on:
- Caddyfile
- portal/**
- gdo/**
- nats/nats.conf
- kanidm/server.toml.tpl
- nats/nats.conf.tpl
- rauthy/config.toml
- deploy-tomtervel
- .gitea/workflows/deploy.yml
workflow_dispatch:
jobs:
deploy:
if: github.ref == 'refs/heads/main'
runs-on: fish
env:
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 }}
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 }}
CONTENT_BRANCH: ${{ vars.CONTENT_BRANCH }}
SITE_NAME: ${{ vars.SITE_NAME }}
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 }}
# What it runs with.
NATS_PASSWORD: ${{ secrets.NATS_PASSWORD }}
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 }}
# Optional: Rauthy beside or instead of Kanidm (README.md, "Rauthy").
# RAUTHY_HOST and the three secrets run it (with `rauthy` in
# COMPOSE_PROFILES); OIDC_ISSUER moves portal's and the chat's
# sign-in to it; RAUTHY_API_KEY lets portal make accounts there.
RAUTHY_HOST: ${{ vars.RAUTHY_HOST }}
RAUTHY_ENC_KEY: ${{ secrets.RAUTHY_ENC_KEY }}
RAUTHY_SECRET_RAFT: ${{ secrets.RAUTHY_SECRET_RAFT }}
RAUTHY_SECRET_API: ${{ secrets.RAUTHY_SECRET_API }}
OIDC_ISSUER: ${{ vars.OIDC_ISSUER }}
RAUTHY_API_KEY: ${{ secrets.RAUTHY_API_KEY }}
RAUTHY_LANGUAGE: ${{ vars.RAUTHY_LANGUAGE }}
steps:
# A missing value stops here, by name, before anything on the host
# is touched. Only names are printed: the log is public.
- name: Write the env files
run: |
missing=
for v in PORTAL_HOST ID_HOST CHAT_HOST PORTAL_RELEASE GDO_RELEASE CNATS_TAG \
KRON_RELEASE CONTENT_REPO CONTENT_BRANCH SITE_NAME PEOPLE_BACKEND \
RESPONSIBLE_GROUP OAUTH2_CLIENT_ID CHAT_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
[ -n "${!v}" ] || missing="$missing $v"
done
[ -z "$missing" ] || { echo "not set as an Actions variable or secret:$missing"; exit 1; }
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
COMPOSE_PROFILES=$COMPOSE_PROFILES
RAUTHY_HOST=$RAUTHY_HOST
OIDC_ISSUER=$OIDC_ISSUER
EOF
cat > "$STAGE/portal.env" <<EOF
NATS_URL=nats://portal:$NATS_PASSWORD@nats:4222
PUBLIC_URL=https://$PORTAL_HOST
KANIDM_URL=https://$ID_HOST
CHAT_URL=https://$CHAT_HOST
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
SITE_NAME=$SITE_NAME
PEOPLE_BACKEND=$PEOPLE_BACKEND
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
EOF
# Rauthy's secrets, only where it runs. The first admin is the
# vel's first person.
if [ -n "$RAUTHY_ENC_KEY" ]; then
for v in RAUTHY_HOST RAUTHY_SECRET_RAFT RAUTHY_SECRET_API; do
[ -n "${!v}" ] || { echo "RAUTHY_ENC_KEY is set, but not $v"; exit 1; }
done
cat > "$STAGE/rauthy.env" <<EOF
ENC_KEYS=$RAUTHY_ENC_KEY
ENC_KEY_ACTIVE=${RAUTHY_ENC_KEY%%/*}
HQL_SECRET_RAFT=$RAUTHY_SECRET_RAFT
HQL_SECRET_API=$RAUTHY_SECRET_API
BOOTSTRAP_ADMIN_EMAIL=$SEED_ADMIN_EMAIL
RAUTHY_ADMIN_EMAIL=$SEED_ADMIN_EMAIL
EVENT_EMAIL=$SEED_ADMIN_EMAIL
EOF
fi
- name: Pull and bring the stack up
run: sudo /usr/local/bin/deploy-tomtervel
+63
View File
@@ -0,0 +1,63 @@
# tomtervel.no's DNS: dns/dnsconfig.js, applied to Cloudflare by
# DNSControl on kasse's host runner. A push that touches dns/, on any
# branch, shows what would change (`preview`) and changes nothing. The
# change itself is a person's: Actions -> dns -> Run workflow, on main.
# So merging is not the cutover; pressing the button is.
#
# Push only, never pull_request: the repo is public, and a stranger's pull
# request must not run on kasse with the token. The token is the repo
# secret CLOUDFLARE_API_TOKEN, DNS edit for tomtervel.no only
# (dns/README.md).
name: dns
on:
push:
paths:
- dns/**
- .gitea/workflows/dns.yml
workflow_dispatch:
jobs:
dns:
runs-on: fish
env:
DNSCONTROL_VERSION: ${{ vars.DNSCONTROL_VERSION }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
steps:
- uses: actions/checkout@v4
# The release binary, fetched once per version into the runner's
# own cache (its built-in cache server) and checked against the
# release's checksums when it is.
- name: Cache dnscontrol
id: cache
uses: actions/cache@v4
with:
path: ~/.cache/dnscontrol
key: dnscontrol-${{ vars.DNSCONTROL_VERSION }}-linux-amd64
- name: Fetch dnscontrol
if: steps.cache.outputs.cache-hit != 'true'
run: |
[ -n "$DNSCONTROL_VERSION" ] || { echo "the DNSCONTROL_VERSION variable is not set"; exit 1; }
mkdir -p ~/.cache/dnscontrol
cd "$(mktemp -d)"
base="https://github.com/StackExchange/dnscontrol/releases/download/v$DNSCONTROL_VERSION"
tar="dnscontrol_${DNSCONTROL_VERSION}_linux_amd64.tar.gz"
curl -sfLO "$base/$tar"
curl -sfLO "$base/checksums.txt"
grep " $tar\$" checksums.txt | sha256sum -c -
tar -xzf "$tar" dnscontrol
install -m 0755 dnscontrol ~/.cache/dnscontrol/dnscontrol
- name: check
working-directory: dns
run: ~/.cache/dnscontrol/dnscontrol check
- name: preview
working-directory: dns
run: ~/.cache/dnscontrol/dnscontrol preview
- name: push
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
working-directory: dns
run: ~/.cache/dnscontrol/dnscontrol push
+3 -1
View File
@@ -2,8 +2,10 @@
portal.env
chat.env
kanidm/server.toml
nats/nats.conf
certs/
.kanidm-recovered
gitea-oauth.secret
dns/cloudflare.env
nats.env
kanidm-setup.secrets
rauthy.env
+97 -8
View File
@@ -20,14 +20,18 @@ so nothing about the vel's members or records depends on anyone else.
## 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):
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`):
```sh
git clone https://prosjekt.klingenbergbygg.no/tomtervel/infrastructure /srv/tomtervel/infrastructure
cd /srv/tomtervel/infrastructure
cp .env.example .env # set PORTAL_HOST and ID_HOST; DNS must point here
sudo sh bootstrap.sh # renders configs, makes the internal cert, starts, recovers Kanidm admin
sh kanidm-setup.sh # logs in, creates the portal client and desk groups, restarts portal
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
# 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;
@@ -80,7 +84,7 @@ and is safe to rerun:
- **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.** `SEED_ADMIN_EMAIL` in `.env`: at start,
- **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.
- **The people who ask the questions.** Everyone a page names as
@@ -124,9 +128,94 @@ Until then, `podman compose restart portal` picks up new content.
## Upgrading portal
Bump `PORTAL_RELEASE` in `.env` (a tag of uhhm/portal) and
`podman compose up -d --build portal`. Keep `IRIS_RELEASE` in the
content repo's workflow matched to it.
Set the org variable `PORTAL_RELEASE` (a tag of uhhm/portal) and run the
deploy workflow. The content repo's lint reads the same variable, so the
two cannot drift apart.
## Variables and secrets
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
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_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` |
| `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` |
| `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 |
| `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_HOST` | variable | repo | optional, Rauthy (see [Rauthy](#rauthy)): `konto.tomtervel.no` |
| `RAUTHY_ENC_KEY`, `RAUTHY_SECRET_RAFT`, `RAUTHY_SECRET_API` | secret | repo | optional, Rauthy's own: made once, never changed (the key encrypts its database) |
| `OIDC_ISSUER` | variable | repo | optional: `https://konto.tomtervel.no/auth/v1/` moves the site's and the chat's sign-in to Rauthy; unset, Kanidm |
| `RAUTHY_API_KEY`, `RAUTHY_LANGUAGE` | secret, variable | repo | optional: portal makes accounts in Rauthy (`<name>$<secret>`, made in Rauthy's admin), in `nb` |
A variable is printed wherever a workflow echoes it, and this repo's run
logs are public: a value that must not be read is a secret.
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).
## Rauthy
Kanidm has no Norwegian: its sign-in, its account pages and its mail
are in English. [Rauthy](https://github.com/sebadob/rauthy) has
Norwegian (`nb`) in all three, and portal (from the release after
0.14.2) and the chat can sign in through it. It is here as a compose
profile, off until it is asked for, so the vel can try it beside
Kanidm and move when it is ready. Portal keeps the groups either way
(`PEOPLE_BACKEND=memberships`), so moving takes no groups along.
Trying it, beside Kanidm:
1. The secrets, made once and never changed:
```sh
echo "$(openssl rand -hex 4)/$(openssl rand -base64 32)" | gt secret set RAUTHY_ENC_KEY -R tomtervel/infrastructure
openssl rand -hex 24 | gt secret set RAUTHY_SECRET_RAFT -R tomtervel/infrastructure
openssl rand -hex 24 | gt secret set RAUTHY_SECRET_API -R tomtervel/infrastructure
gt variable set RAUTHY_HOST --body konto.tomtervel.no -R tomtervel/infrastructure
gt variable set COMPOSE_PROFILES --body chat,rauthy -R tomtervel/infrastructure
```
2. DNS: `konto` is in `dns/dnsconfig.js`; run the dns workflow. Install
`host-caddy/tomtervel.no` on kasse (it has the `konto` block) and
reload Caddy. Reinstall `deploy-tomtervel` on kasse too: it now puts
`rauthy.env` in place.
3. Deploy. The first admin is `SEED_ADMIN_EMAIL`; its password is in the
log once: `podman compose logs rauthy | grep -A2 -i password`.
4. In Rauthy's admin (`https://konto.tomtervel.no/auth/v1/admin`): a
client for the site (`authorization_code`, `S256`, scopes `openid
profile email`, redirect `https://tomtervel.no/auth/callback`) and
one for the chat (also `refresh_token`, redirect
`https://chat.tomtervel.no/auth/callback`), and an API key with read
and create on users.
5. Moving the sign-in over is then values: `OIDC_ISSUER`,
`OAUTH2_CLIENT_ID`/`OAUTH2_CLIENT_SECRET` and the chat's pair set to
Rauthy's clients, `RAUTHY_API_KEY`, `RAUTHY_LANGUAGE=nb`, and a
portal release that knows them. Back is the same values unset.
Rauthy's mail leaves through kasse's postfix like gdo's, and Rauthy
stops if it cannot reach it. Its database is in the `rauthy_data`
volume, which wants the same backups as NATS.
## Backups
+23 -41
View File
@@ -1,45 +1,26 @@
#!/bin/sh
# First start on a fresh host. Idempotent: rerunning renders configs
# again and skips what exists. Needs podman + podman-compose and openssl,
# and DNS for PORTAL_HOST and ID_HOST already pointing here. Run rootful
# (as root) so Caddy can bind 80/443 and Kanidm sees a stable source IP.
# 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.
#
# cp .env.example .env # fill in the hosts
# sudo sh bootstrap.sh
# 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 ] || { echo "copy .env.example to .env and fill it in first"; exit 1; }
. ./.env
[ -f .env ] && . ./.env
: "${ID_HOST:?ID_HOST=id.<the vel's domain> sh bootstrap.sh, or run the deploy workflow first}"
# A NATS password, once.
if [ -z "${NATS_PASSWORD:-}" ]; then
NATS_PASSWORD=$(openssl rand -base64 36 | tr -d '/+=' | cut -c1-40)
sed -i "s|^NATS_PASSWORD=.*|NATS_PASSWORD=$NATS_PASSWORD|" .env
echo "NATS_PASSWORD generated into .env"
fi
# Rendered configs (gitignored).
# 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
sed "s|\${NATS_PASSWORD}|$NATS_PASSWORD|g" nats/nats.conf.tpl > nats/nats.conf
# The onboarding token is written by kanidm-setup.sh, once; a rerun of
# this script must not lose it, or every invite fails closed again.
kept_token=$(grep '^KANIDM_API_TOKEN=' portal.env 2>/dev/null | head -1 || true)
cat > portal.env <<EOF
NATS_URL=nats://portal:$NATS_PASSWORD@nats:4222
KANIDM_URL=https://$ID_HOST
OAUTH2_CLIENT_ID=$OAUTH2_CLIENT_ID
OAUTH2_CLIENT_SECRET=${OAUTH2_CLIENT_SECRET:-}
PUBLIC_URL=https://$PORTAL_HOST
COOKIE_SECURE=true
CONTENT_REPO=$CONTENT_REPO
CONTENT_BRANCH=$CONTENT_BRANCH
SITE_NAME=$SITE_NAME
SEED_ADMIN_EMAIL=${SEED_ADMIN_EMAIL:-}
SEED_ADMIN_NAME=${SEED_ADMIN_NAME:-}
RESPONSIBLE_GROUP=${RESPONSIBLE_GROUP:-}
EOF
[ -n "$kept_token" ] && echo "$kept_token" >> portal.env
chmod 600 portal.env
echo "kanidm/server.toml made for $ID_HOST"
}
# Kanidm's internal certificate: Caddy holds the public one.
mkdir -p certs
@@ -51,12 +32,13 @@ if [ ! -f certs/kanidm-key.pem ]; then
echo "internal Kanidm certificate made"
fi
podman compose up -d --build
echo "containers up; Caddy is fetching certificates for $PORTAL_HOST and $ID_HOST"
# The Kanidm admin accounts exist only after the first start; their
# passwords are set by recovery. Do this once; the output is the
# password, shown once.
# 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) ==="
+38 -3
View File
@@ -42,6 +42,8 @@ services:
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
volumes:
- ./nats/nats.conf:/etc/nats/nats.conf:ro
- nats_data:/data
@@ -79,12 +81,40 @@ services:
ports:
- "127.0.0.1:8443:8443"
# Rauthy: sign-in, account pages and account mail in Norwegian, as an
# alternative to Kanidm (which has no Norwegian). A profile, off unless
# COMPOSE_PROFILES has `rauthy`; with it, portal and the chat sign in
# here when OIDC_ISSUER is set, and portal makes accounts here with
# RAUTHY_API_KEY. Its database is embedded (hiqlite), in rauthy_data.
# Host-published for kasse's host Caddy (RAUTHY_HOST -> here).
rauthy:
profiles: ["rauthy"]
image: ghcr.io/sebadob/rauthy:${RAUTHY_TAG:-0.37.2}
restart: unless-stopped
env_file:
- path: rauthy.env
required: false
environment:
PUB_URL: ${RAUTHY_HOST:-no-host-set}
RP_ID: ${RAUTHY_HOST:-no-host-set}
# Rauthy wants the port spelled out.
RP_ORIGIN: https://${RAUTHY_HOST:-no-host-set}:443
extra_hosts:
- "host.containers.internal:host-gateway"
volumes:
- ./rauthy/config.toml:/app/config.toml:ro
- rauthy_data:/app/data
ports:
- "127.0.0.1:8090:8080"
portal:
build:
context: ./portal
args:
PORTAL_RELEASE: ${PORTAL_RELEASE}
restart: unless-stopped
# Written by the deploy workflow from the Actions variables and
# secrets (README.md has the table).
env_file: portal.env
environment:
LEPTOS_SITE_ADDR: 0.0.0.0:3000
@@ -121,8 +151,9 @@ services:
args:
GDO_RELEASE: ${GDO_RELEASE}
restart: unless-stopped
# NATS_URL, with the password: made by bootstrap.sh, never committed.
env_file: nats.env
environment:
NATS_URL: nats://portal:${NATS_PASSWORD}@nats:4222
# The host, from inside the container. Podman resolves this to the
# gateway; the host's postfix listens on 0.0.0.0:25.
SMTP_HOST: host.containers.internal
@@ -151,14 +182,17 @@ services:
image: docker.io/bendik/cnats:${CNATS_TAG:-no-tag-set}
restart: unless-stopped
env_file:
- nats.env
- path: chat.env
required: false
environment:
# Must be the portal's own: a new name is a new, empty chat.
SITE_NAME: tomtervel
NATS_URL: nats://portal:${NATS_PASSWORD}@nats:4222
KANIDM_URL: https://${ID_HOST}
PUBLIC_URL: https://${CHAT_HOST:-chat.vel.klingenbergbygg.no}
# Set, the chat signs in through it instead of Kanidm (Rauthy:
# https://<RAUTHY_HOST>/auth/v1/). Empty is unset.
OIDC_ISSUER: ${OIDC_ISSUER:-}
PUBLIC_URL: https://${CHAT_HOST}
COOKIE_SECURE: "true"
ports:
- "127.0.0.1:3070:3000"
@@ -184,6 +218,7 @@ volumes:
caddy_config:
nats_data:
kanidm_data:
rauthy_data:
learn_cache:
# Pin the project network subnet inside 172.16/12 so Kanidm's X-Forwarded-For
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
# Tomter Vel's stack, brought up from its own repo. This is the whole of
# what CI may do as root for the vel: pull main, put the env files the
# deploy workflow wrote in place, and bring the compose project up. It
# takes no arguments, so there is nothing for a workflow to point
# somewhere else.
#
# The env files come from the repo's and org's Actions variables and
# secrets: the workflow writes them, as the runner, into $stage (the
# runner's own, 0700), and this script moves them into the checkout as
# root's, 0600, and leaves nothing behind in $stage.
#
# Install: sudo install -m 0755 -o root -g root \
# deploy-tomtervel /usr/local/bin/deploy-tomtervel
# Grant: gitea-runner ALL=(root) NOPASSWD: /usr/local/bin/deploy-tomtervel
set -euo pipefail
root=/srv/tomtervel/infrastructure
stage=/var/lib/gitea-runner/tomtervel-env
files=(.env portal.env nats.env chat.env)
# Written only when the site runs what needs it (Rauthy).
optional=(rauthy.env)
[ -d "$root/.git" ] || { echo "no checkout at $root - bootstrap it first" >&2; exit 1; }
for f in "${files[@]}"; do
[ -s "$stage/$f" ] || { echo "no $stage/$f - the deploy workflow writes it" >&2; exit 1; }
done
cd "$root"
git fetch --quiet origin main
git reset --hard --quiet origin/main
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
# The vel's portal, reached the way the host Caddy reaches it. No
# forwarded header on purpose: a check that sends the one Caddy sends
# cannot tell you the site is broken for everything that is not Caddy.
code=000
for n in $(seq 1 30); do
code=$(curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:3050/ || true)
[ "$code" = 200 ] && break
sleep 2
done
podman compose ps --format '{{.Names}} {{.State}}' || true
echo "portal http $code after $((n * 2))s"
[ "$code" = 200 ]
+16 -5
View File
@@ -5,6 +5,16 @@ The zone is `dnsconfig.js`, applied to Cloudflare with
the file with the live zone, so it can be run by anyone with the token,
from any machine.
## From CI
`.gitea/workflows/dns.yml` runs on kasse's host runner. Every push that
touches `dns/`, on any branch, runs `check` and `preview`: the run's log
is the diff, and nothing changes. Applying it is a person pressing
**Actions -> dns -> Run workflow** on `main`, so merging is never the
cutover by accident. The token is the repo secret `CLOUDFLARE_API_TOKEN`.
## By hand
```sh
paru -S dnscontrol
cd dns
@@ -48,13 +58,14 @@ Nothing about Zoho's MX should appear.
1. On kasse, `kasse-dkim-tomtervel.sh` makes the vel's signing key and
prints its public half. Put it in `KASSE_DKIM`.
2. `dnscontrol push`. The apex leaves the old website at this moment.
3. `.env` here: `PORTAL_HOST=tomtervel.no`, `ID_HOST=id.tomtervel.no`,
`CHAT_HOST=chat.tomtervel.no`, and the Caddy blocks in
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.
4. Only then `mail.from: post@tomtervel.no` in the content repo's
`site.yaml`; before step 2 that mail fails every check.
The hosts in `dnsconfig.js` and in `.env` are the same names and have to
stay so; DNSControl does not read `.env`.
The hosts in `dnsconfig.js` and the `*_HOST` variables are the same names
and have to stay so; DNSControl does not read the variables.
+9 -1
View File
@@ -20,7 +20,7 @@ var KASSE = "195.159.177.252";
// `kasse`). It is the public half, printed by kasse-dkim-tomtervel.sh;
// the private half stays on kasse. Empty: no record yet, and the site
// must keep sending from klingenbergbygg.no (site.yaml `mail.from`).
var KASSE_DKIM = "";
var KASSE_DKIM = "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnFk6GpG/SKmBsed+iiuDQZmyZB/SyUqAqMsEDhZTzMSy8m4hW1TPhIUwZmq4c9RTyX8OPM8FhQMiMLjpAxWHQeOMV6AesbpCU+bdTZBddJyLFF5D7o5UKIEUuByAuZbBAvX0R/irQAtNbgeYiDpRwtg60dpoR6HfhA71xBKu8k4C0N4fMQk+SZundzCrOPVGQKSZUVcl5cH92V9SiRlj3y9SFlQIbqaJLA9F3zF4O4yJZ378ov93PFmGyHyG6OhA1KS6aFHxUbxflolKffXXbSjQUZvOhw/+zXEd0agCOmZVYOoeQcZdeHa59qdA7MV2P1/lfbDKHnuTVNiq8zI5kwIDAQAB";
D("tomtervel.no", REG_NONE, DnsProvider(DSP_CLOUDFLARE),
DefaultTTL(1), // Cloudflare's "auto"
@@ -32,6 +32,14 @@ D("tomtervel.no", REG_NONE, DnsProvider(DSP_CLOUDFLARE),
CNAME("www", "tomtervel.no.", CF_PROXY_OFF),
A("id", KASSE, CF_PROXY_OFF),
A("chat", KASSE, CF_PROXY_OFF),
// Rauthy, the Norwegian sign-in, beside Kanidm while the vel tries it.
A("konto", KASSE, CF_PROXY_OFF),
// The old website, kept for now so the move can be undone: what the
// apex and web. pointed at before (Netlify, through Cloudflare). The
// old host must also know the name (a domain alias there). Drop it
// when nobody needs the old site.
A("gammel", "104.198.14.52", CF_PROXY_ON),
// The board's inbox, post@tomtervel.no, is at Zoho.
MX("@", 10, "mx.zoho.eu."),
+49
View File
@@ -0,0 +1,49 @@
# 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
}
# Tomter Vel's own Kanidm. Caddy holds the public certificate; Kanidm
# speaks TLS internally with a self-signed one, on a loopback port, so
# that hop is not verified. The @brand files are the vel's: the name in
# the tab, the icons, and the stylesheet Kanidm serves empty for a site
# to fill (written by go-live.sh brand into /srv/tomtervel/brand).
id.tomtervel.no {
@brand path /pkg/override.css /manifest.webmanifest /pkg/img/favicon.png /pkg/img/logo.svg /pkg/img/logo-square.svg /pkg/img/logo-180.png /pkg/img/logo-192.png /pkg/img/logo-256.png /pkg/img/logo-512.png /pkg/img/kani-warning.svg /pkg/img/kani-waving.svg
handle @brand {
root * /srv/tomtervel/brand
uri strip_prefix /pkg/img
uri strip_prefix /pkg
header Cache-Control "public, max-age=3600"
@manifest path /manifest.webmanifest
header @manifest Content-Type application/manifest+json
file_server
}
handle {
reverse_proxy https://127.0.0.1:8443 {
transport http {
tls_insecure_skip_verify
}
}
}
}
chat.tomtervel.no {
reverse_proxy 127.0.0.1:3070
}
# Rauthy (compose profile `rauthy`): sign-in and account pages in
# Norwegian, beside Kanidm until the vel moves over (README.md, "Rauthy").
# Plain http on a loopback port; Caddy holds the certificate.
konto.tomtervel.no {
reverse_proxy 127.0.0.1:8090
}
+17 -11
View File
@@ -12,6 +12,11 @@
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
@@ -163,33 +168,34 @@ if [ -n "${GITEA_URL:-}" ] && [ -n "${RESPONSIBLE_GROUP:-}" ]; then
fi
fi
# Secrets into portal.env, never printed. The token is shown once, by
# Kanidm, at creation; a rerun keeps the one portal.env already has.
# 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)
sed -i "s|^OAUTH2_CLIENT_SECRET=.*|OAUTH2_CLIENT_SECRET=$secret|" .env
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
# The first person in, if .env names one: portal invites them into the
# most privileged group on its next start, once, and mails the link.
if [ -n "${SEED_ADMIN_EMAIL:-}" ]; then setenv SEED_ADMIN_EMAIL "$SEED_ADMIN_EMAIL"; fi
if [ -n "${SEED_ADMIN_NAME:-}" ]; then setenv SEED_ADMIN_NAME "$SEED_ADMIN_NAME"; fi
if [ -n "${RESPONSIBLE_GROUP:-}" ]; then setenv RESPONSIBLE_GROUP "$RESPONSIBLE_GROUP"; fi
# Where the groups live: `memberships` keeps them in portal, and this
# Kanidm only makes the accounts (portal docs, Memberships).
if [ -n "${PEOPLE_BACKEND:-}" ]; then setenv PEOPLE_BACKEND "$PEOPLE_BACKEND"; 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:"
+3 -2
View File
@@ -1,5 +1,6 @@
# NATS with JetStream: portal's records, events and projections live
# here. bootstrap.sh renders this into nats.conf from .env.
# here. The password is NATS_PASSWORD from the container's environment
# (nats.env, written by the deploy workflow from the org secret).
port: 4222
http_port: 8222
@@ -10,7 +11,7 @@ max_connections: 1000
# (nats://user:pass@host) behave the same in every client library.
authorization {
users = [
{ user: "portal", password: "${NATS_PASSWORD}" }
{ user: "portal", password: $NATS_PASSWORD }
]
}
+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"]