refactor(mail): send via the SSO app registration, drop SMTP basic auth
Docker Image bauen und veroeffentlichen / build-and-push (push) Successful in 2m25s

Mail now uses the same Entra ID app registration as "Sign in with
Microsoft" (ENTRA_TENANT_ID, ENTRA_CLIENT_ID, ENTRA_CLIENT_SECRET), so
only one enterprise application is needed. The app additionally gets
the SMTP.SendAsApp permission; Exchange still limits it to the mailbox
granted via Add-MailboxPermission.

Password (basic auth) sending is removed entirely: SMTP_HOST, SMTP_PORT,
SMTP_PASSWORD and the separate SMTP_OAUTH_* settings are gone. The
transport is fixed to smtp.office365.com:587 with required STARTTLS.
SMTP_USER (sending mailbox) and SMTP_FROM remain.

- lib/entra.ts exposes readEntraAppCredentials(), shared by SSO and mail
- diagnosis drops basic-auth-only causes; hints name the ENTRA_* values
  and warn that an expired secret breaks sign-in and mail together
- admin e-mail test, .env.example, docker-compose, k8s manifests,
  preflight and README updated

Verified against Entra ID with fake values: token error classified,
client secret never exposed, missing ENTRA_CLIENT_SECRET reported.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Nick SzaunigandClaude Opus 5.5 committed 2026-09-26 19:23:05 +02:00
1 parent 0620e9d79a
commit 11910dd6dd
15 files changed
+211 -309

No files matched your search

+14 -9
View File
@@ -79,16 +79,16 @@ GOOGLE_PLACE_ID=
TURNSTILE_SECRET_KEY=
NEXT_PUBLIC_TURNSTILE_SITE_KEY=
# SMTP fuer Transaktions-E-Mails (Bestellbestaetigung, Newsletter-Opt-in,
# Passwort-Reset). Ohne diese drei Werte werden E-Mails nur geloggt statt
# versendet — praktisch fuer lokale Entwicklung ohne Mail-Setup.
# Funktioniert mit jedem SMTP-Anbieter (z.B. das E-Mail-Postfach eures
# Domain-Hosters wie IONOS/Strato, oder ein Dienst wie Resend/Postmark im
# SMTP-Modus).
SMTP_HOST=
SMTP_PORT=587
# Transaktions-E-Mails (Bestellbestaetigung, Newsletter-Opt-in,
# Passwort-Reset) gehen ueber Microsoft 365 mit OAuth 2.0 — mit derselben
# App-Registrierung wie "Mit Microsoft anmelden" (ENTRA_* weiter unten, dort
# zusaetzlich die Berechtigung SMTP.SendAsApp, siehe README
# "E-Mail-Versand"). Ein Passwort gibt es nicht. Ohne SMTP_USER und die
# ENTRA_*-Werte werden E-Mails nur geloggt statt versendet — praktisch fuer
# lokale Entwicklung ohne Mail-Setup.
# SMTP_USER = das Postfach, mit dem gesendet wird; SMTP_FROM sollte dieselbe
# Adresse tragen.
SMTP_USER=
SMTP_PASSWORD=
SMTP_FROM="Wabenhain <[email protected]>"
# ApiCore-Synchronisierung (optional). Zwei Knoepfe nutzen sie: admin/ernten
@@ -187,6 +187,11 @@ DHL_ENVIRONMENT=sandbox
# als Unternehmensapplikation (wird beim App-Registration-Schritt
# automatisch mit angelegt) — dort laesst sich optional der Nutzerkreis
# (z.B. nur bestimmte Gruppen) einschraenken.
# 6. Dieselbe App versendet auch die Shop-E-Mails (SMTP_USER oben): dafuer
# die Anwendungsberechtigung "Office 365 Exchange Online -> SMTP.SendAsApp"
# mit Administratorzustimmung ergaenzen und in Exchange das Postfach
# freigeben (README "E-Mail-Versand"). Laeuft das Secret ab, sind
# Anmeldung UND Mailversand betroffen.
ENTRA_TENANT_ID=
ENTRA_CLIENT_ID=
ENTRA_CLIENT_SECRET=