Files
claudeandClaude Opus 5.5 99687ea231 Own LDAP account and mail, Harmony Users gate, Dex-only sign-in UI
- tasks/ldap.yml keeps cn=Harmony (harmony@eom.dev): password from Vault,
  in Harmony Users, Postfix Users and Dovecot Users. GoTrue sends as it,
  and it is an instance admin alongside eric@eom.dev.
- theme.js hides the e-mail/password form; Register and /register (also in
  Caddy) go to https://www.eom.dev/members/.
- The Dex button uses the square eom.dev icon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 17:44:29 -05:00

44 lines
1.7 KiB
Django/Jinja

#!/bin/sh
# Runs inside the OpenLDAP pod (its LDAP_ADMIN_PASSWORD), from tasks/ldap.yml.
# Makes sure the service's LDAP account exists, has the password from Vault
# and is in its groups; prints "changed=N".
set -eu
l() { c=$1; shift; "$c" -x -H ldap://localhost -D "cn=admin,{{ harmony_ldap_base_dn }}" -w "$LDAP_ADMIN_PASSWORD" "$@"; }
DN={{ _harmony_ldap_dn | quote }}
PW=$(printf %s {{ harmony_smtp_password | b64encode | quote }} | base64 -d)
changed=0
if ! l ldapsearch -LLL -s base -b "$DN" dn >/dev/null 2>&1; then
uidn=$(l ldapsearch -LLL -b {{ harmony_ldap_base_dn | quote }} "(uidNumber=*)" uidNumber |
awk '/^uidNumber:/ { print $2 }' | sort -n | tail -1)
printf '%s\n' \
"dn: $DN" \
"objectClass: inetOrgPerson" \
"objectClass: posixAccount" \
"objectClass: top" \
"cn: {{ harmony_ldap_account.cn }}" \
"sn: {{ harmony_ldap_account.cn }}" \
"uid: {{ harmony_ldap_account.uid }}" \
"uidNumber: $((uidn + 1))" \
"gidNumber: {{ harmony_ldap_account.gid_number }}" \
"homeDirectory: /home/users/{{ harmony_ldap_account.uid }}" \
"mail: {{ harmony_ldap_account.mail }}" | l ldapadd >/dev/null
echo "created $DN" >&2
changed=1
fi
if ! ldapwhoami -x -H ldap://localhost -D "$DN" -w "$PW" >/dev/null 2>&1; then
l ldappasswd -s "$PW" "$DN" >/dev/null
echo "set the password of $DN" >&2
changed=1
fi
{% for group in harmony_ldap_account.groups %}
if ! l ldapsearch -LLL -s base -b {{ group | quote }} "(uniqueMember=$DN)" dn | grep -q '^dn:'; then
printf '%s\n' "dn: {{ group }}" "changetype: modify" "add: uniqueMember" "uniqueMember: $DN" | l ldapmodify >/dev/null
echo "added $DN to {{ group }}" >&2
changed=1
fi
{% endfor %}
echo "changed=$changed"