diff --git a/.env.example b/.env.example index 86e663a..f307066 100644 --- a/.env.example +++ b/.env.example @@ -43,6 +43,14 @@ PEOPLE_BACKEND=memberships 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= diff --git a/.gitignore b/.gitignore index b3cec27..27f4f02 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .env portal.env +chat.env kanidm/server.toml nats/nats.conf certs/ diff --git a/compose.yml b/compose.yml index f0402a2..a5ec1c3 100644 --- a/compose.yml +++ b/compose.yml @@ -140,6 +140,32 @@ services: # published 127.0.0.1:4222 port above, so no in-compose runner — and no # docker.sock/podman.sock mount — is needed here. + # The vel's conversations: every group the content names is a room, + # portal speaks in them and decides who gets in. Its history is on the + # vel's own NATS (stream tomtervel_CHAT); there is no Postgres. A + # profile, since it needs chat.env: go-live sets COMPOSE_PROFILES=chat + # in .env once it is there. Host-published for kasse's host Caddy + # (chat.vel.klingenbergbygg.no -> here). + cnats: + profiles: ["chat"] + image: docker.io/bendik/cnats:${CNATS_TAG:-no-tag-set} + restart: unless-stopped + env_file: + - 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} + COOKIE_SECURE: "true" + ports: + - "127.0.0.1:3070:3000" + depends_on: + nats: + condition: service_healthy + # Where uploads go: the pictures and documents a desk attaches, and what # `portal import` brings in. One node on this host, reachable only inside # the project; nothing is published. go-live.sh garage renders diff --git a/kanidm-setup.sh b/kanidm-setup.sh index d931fcc..878d7c6 100755 --- a/kanidm-setup.sh +++ b/kanidm-setup.sh @@ -15,6 +15,9 @@ cd "$(dirname "$0")" K="kanidm -D idm_admin -H https://$ID_HOST" C=$OAUTH2_CLIENT_ID SA=portal-onboarding +# What a person reads on the sign-in pages. Not SITE_NAME, which from portal +# 0.9 is the site's namespace, `tomtervel`. +SITE_TITLE=${SITE_TITLE:-Tomter Vel} # Already signed in? Then do not ask again: this script is meant to be # rerunnable, and the session outlives a single run. @@ -76,7 +79,7 @@ fi # The OAuth2 client. Everyone in this Kanidm is the vel's, so anyone # may sign in; what they see is decided by their desk groups, which # arrive in the `groups` claim under their own names. -has_client $C || $K system oauth2 create $C "$SITE_NAME" "https://$PORTAL_HOST" +has_client $C || $K system oauth2 create $C "$SITE_TITLE" "https://$PORTAL_HOST" $K system oauth2 add-redirect-url $C "https://$PORTAL_HOST/auth/callback" 2>/dev/null || true $K system oauth2 update-scope-map $C idm_all_persons openid profile email for g in $groups; do @@ -100,7 +103,7 @@ fi # may change - idm_admin gets a bare "Item not found" - so that half # runs when an admin session exists, and otherwise says what to run. A="kanidm -D admin -H https://$ID_HOST" -$K system oauth2 set-displayname $C "$SITE_NAME" >/dev/null || true +$K system oauth2 set-displayname $C "$SITE_TITLE" >/dev/null || true logo=$(mktemp --suffix=.svg) if curl -sfL "$CONTENT_REPO/raw/branch/$CONTENT_BRANCH/images/logo.svg" -o "$logo" && [ -s "$logo" ]; then $K system oauth2 set-image $C "$logo" svg >/dev/null || echo "note: could not set the client logo" @@ -109,7 +112,7 @@ else : > "$logo" fi if $A self whoami >/dev/null 2>&1; then - $A system domain set-displayname "$SITE_NAME" >/dev/null || echo "note: could not set the login page's name" + $A system domain set-displayname "$SITE_TITLE" >/dev/null || echo "note: could not set the login page's name" [ -s "$logo" ] && { $A system domain set-image "$logo" svg >/dev/null || echo "note: could not set the login page's logo"; } else echo "note: the login page's own name and logo need the admin account (bootstrap.sh printed its password):"