2026-11-10 18:07:13 +01:00
|
|
|
#!/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.
|
2026-11-10 20:24:27 +01:00
|
|
|
#
|
|
|
|
|
# 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.
|
2026-11-10 18:07:13 +01:00
|
|
|
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,
|
2026-11-10 20:24:27 +01:00
|
|
|
auto_onboarding: true, auto_link: true }')
|
2026-11-10 18:07:13 +01:00
|
|
|
# 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
|