Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
459f780049 | ||
|
|
97083982ba | ||
|
|
c88d396ad7 | ||
|
|
33e102dc25 | ||
|
|
64fc9a1911 | ||
|
|
b2ee900602 | ||
|
|
b128801ee2 | ||
|
|
fdac5084d1 | ||
|
|
4cf56ac588 | ||
|
|
69489e7e42 | ||
|
|
100002baa2 |
No files matched your search
@@ -77,6 +77,11 @@ jobs:
|
||||
RAUTHY_API_KEY: ${{ secrets.RAUTHY_API_KEY }}
|
||||
RAUTHY_LANGUAGE: ${{ vars.RAUTHY_LANGUAGE }}
|
||||
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
|
||||
@@ -156,6 +161,23 @@ 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"
|
||||
|
||||
- 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
|
||||
@@ -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,7 @@ 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`) |
|
||||
|
||||
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.
|
||||
@@ -152,28 +156,48 @@ 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.
|
||||
|
||||
## Preview
|
||||
## Previews
|
||||
|
||||
`forhandsvisning.tomtervel.no` shows the content branch last pushed to
|
||||
tomtervel/questions, before it is merged. The content repo's
|
||||
`lint-and-reload` workflow runs it after the lint passes: a container
|
||||
`tomtervel-preview` from this site's own image
|
||||
(`localhost/tomtervel-portal:<PORTAL_RELEASE>`), beside a throwaway NATS
|
||||
(`tomtervel-preview-nats`), on 127.0.0.1:3065. It 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.
|
||||
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
|
||||
|
||||
|
||||
+5
-1
@@ -36,8 +36,12 @@ D("tomtervel.no", REG_NONE, DnsProvider(DSP_CLOUDFLARE),
|
||||
// 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 preview: a branch before it is merged.
|
||||
// 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
@@ -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/*
|
||||
|
||||
|
||||
+29
-7
@@ -33,13 +33,35 @@ konto.tomtervel.no {
|
||||
reverse_proxy 127.0.0.1:8090
|
||||
}
|
||||
|
||||
# The content repo's preview: the branch last pushed, on a portal of its
|
||||
# own with a throwaway NATS, no mail and no sign-in (tomtervel/questions,
|
||||
# lint-and-reload.yml). Kept out of search engines.
|
||||
# Port 3065: 3060 is gullberg.klingenbergbygg.no's, and podman's own
|
||||
# published ports (3050, 3070, 8090) do not show in `ss`, so a port is
|
||||
# chosen against this directory's upstreams as well.
|
||||
# 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:3065
|
||||
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
@@ -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
|
||||
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/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.
|
||||
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: false }')
|
||||
# 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
|
||||
Reference in new issue
Block a user