diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 204d0ae..f86f5cc 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -20,6 +20,7 @@ on: - portal/** - gdo/** - rauthy-providers.sh + - rauthy-theme.sh - nats/nats.conf - rauthy/config.toml - deploy-tomtervel @@ -212,3 +213,8 @@ jobs: 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 diff --git a/README.md b/README.md index 0034bea..a5d342a 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,15 @@ 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 diff --git a/rauthy-theme.sh b/rauthy-theme.sh new file mode 100755 index 0000000..fe5829c --- /dev/null +++ b/rauthy-theme.sh @@ -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