fix(idle-daemon): sync MS_OAUTH_SCOPES with backend — drop User.Read, add email

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) <noreply@anthropic.com>
This commit is contained in:
chahinebrini 2026-05-13 23:33:39 +02:00
parent 2e285beefd
commit fd1cb912f7

View File

@ -173,11 +173,16 @@ function encrypt(plaintext) {
const MS_TOKEN_ENDPOINT = const MS_TOKEN_ENDPOINT =
"https://login.microsoftonline.com/common/oauth2/v2.0/token"; "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 = [ const MS_OAUTH_SCOPES = [
"https://outlook.office.com/IMAP.AccessAsUser.All", "https://outlook.office.com/IMAP.AccessAsUser.All",
"offline_access", "offline_access",
"openid", "openid",
"User.Read", "email",
].join(" "); ].join(" ");
/** /**