From fd1cb912f77cad70b963d8e677ee56edac6adc6c Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Wed, 13 May 2026 23:33:39 +0200 Subject: [PATCH] =?UTF-8?q?fix(idle-daemon):=20sync=20MS=5FOAUTH=5FSCOPES?= =?UTF-8?q?=20with=20backend=20=E2=80=94=20drop=20User.Read,=20add=20email?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mo-Befund: Daemon hat sein eigenes MS_OAUTH_SCOPES-Array, das durch den Backend-Fix von gestern Abend nicht erreicht wurde. Token-Refresh-Call im Daemon nutzte noch User.Read → Microsoft wirft AADSTS70011 "scopes not compatible" → setMailConnectionAuthBroken → Frontend zeigt "Auth-Fehler" (vorher: stiller Hang via getMailboxLock-Timeout). Daemon-Scopes jetzt synchron zu backend/server/utils/ms-oauth.ts: - IMAP.AccessAsUser.All (Outlook-Resource) - offline_access (cross-resource) - openid (OIDC, cross-resource) - email (OIDC, cross-resource — liefert email-Claim) Folge-Aktion für User: bestehende Outlook-Connection muss neu verbunden werden, weil der gespeicherte refresh_token von Microsoft mit den alten inkompatiblen Scopes ausgestellt wurde. Disconnect + re-OAuth in der App. Co-Authored-By: Claude Opus 4.7 (1M context) --- backend/imap-idle/index.mjs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/imap-idle/index.mjs b/backend/imap-idle/index.mjs index 82ce72f..8c5bef5 100644 --- a/backend/imap-idle/index.mjs +++ b/backend/imap-idle/index.mjs @@ -173,11 +173,16 @@ function encrypt(plaintext) { const MS_TOKEN_ENDPOINT = "https://login.microsoftonline.com/common/oauth2/v2.0/token"; +// MUSS identisch zu backend/server/utils/ms-oauth.ts MS_OAUTH_SCOPES sein. +// Microsoft V2.0 erlaubt im /token-Exchange nur Scopes EINES Resource-Servers +// — `User.Read` (graph.microsoft.com) mit `IMAP.AccessAsUser.All` +// (outlook.office.com) wirft AADSTS70011. `email` ist ein OIDC-Standard-Scope +// und damit cross-resource-kompatibel; liefert den email-Claim ins id_token. const MS_OAUTH_SCOPES = [ "https://outlook.office.com/IMAP.AccessAsUser.All", "offline_access", "openid", - "User.Read", + "email", ].join(" "); /**