From 5310b87fe51429f41a347db5893fef2185ea294e Mon Sep 17 00:00:00 2001 From: Niek Rabelink Date: Thu, 10 Sep 2026 14:47:34 +0200 Subject: [PATCH] feat(microsoft-integration): update Microsoft 365 settings and admin consent handling for improved clarity and functionality --- admin.php | 32 ++++++++++++++++++++------------ auth/callback_microsoft.php | 13 +++++++------ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/admin.php b/admin.php index 75196ce..8b60250 100644 --- a/admin.php +++ b/admin.php @@ -64,7 +64,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { "); $stmt->execute([$userId, $isDemo, json_encode($newSettings)]); - $message = "Centrale Microsoft 365 Azure App instellingen zijn succesvol opgeslagen."; + $message = "Centrale Microsoft 365 instellingen (Agenda, E-mail & Teams) zijn succesvol opgeslagen."; $messageType = 'success'; } @@ -390,7 +390,7 @@ require_once __DIR__ . '/includes/header.php';
- +
@@ -399,7 +399,7 @@ require_once __DIR__ . '/includes/header.php';
-

Microsoft 365 & Azure App Registratie

+

Microsoft 365 Koppeling (Agenda, E-mail & Teams)

Geconfigureerd @@ -410,12 +410,12 @@ require_once __DIR__ . '/includes/header.php';
-

Centrale OAuth 2.0 instellingen voor de hele organisatie

+

Centrale OAuth 2.0 koppeling voor Outlook Agenda, E-mail (Postvak IN) en Microsoft Teams

- + Admin Consent Verlenen @@ -480,10 +480,10 @@ require_once __DIR__ . '/includes/header.php';
- Zodra opgeslagen kunnen al uw collega's met 1 klik hun Outlook agenda koppelen. + Zodra opgeslagen en goedgekeurd kunnen al uw collega's met 1 klik hun Outlook agenda én e-mail koppelen.
@@ -493,7 +493,7 @@ require_once __DIR__ . '/includes/header.php'; @@ -502,28 +502,36 @@ require_once __DIR__ . '/includes/header.php';
1
- Azure Portal: Ga naar portal.azure.com → Microsoft Entra ID → App registrations → New registration. Kies "Accounts in this organizational directory only" (single-tenant). + Azure Portal: Ga naar portal.azure.com → Microsoft Entra ID → App registrations → New registration (of open de bestaande Fociz app). Kies "Accounts in this organizational directory only" (single-tenant).
2
- Redirect URI: Kies platform Web en vul exact in: . + Redirect URI: Ga naar Authentication, kies platform Web en vul exact in: .
3
- API Permissions: Ga naar API permissions → Add a permission → Microsoft Graph → Delegated permissions → Vink aan: User.Read, Calendars.ReadWrite, Mail.ReadWrite en Mail.Send. + API Permissions (Agenda, E-mail & Teams): Ga naar API permissions → Add a permission → Microsoft Graph → Delegated permissions → Vink de volgende machtigingen aan: +
    +
  • User.Read — Aanmelden en basisprofiel
  • +
  • Calendars.ReadWrite — Outlook agenda synchronisatie & afspraken inplannen
  • +
  • Mail.ReadWrite — Outlook inbox e-mails lezen, inplannen & beheren
  • +
  • Mail.Send — E-mails direct beantwoorden en doorsturen vanuit Fociz
  • +
  • OnlineMeetings.ReadWrite — Automatische Teams-vergaderingen koppelen
  • +
  • offline_access — Verbinding actief houden op de achtergrond
  • +
4
- Beheerdersgoedkeuring (Admin Consent): Klik op "Grant admin consent for [Uw Organisatie]". Er verschijnt direct een groen vinkje bij alle regels. Hiermee hoeven individuele collega's geen beheerder meer te vragen! + Beheerdersgoedkeuring (Admin Consent): Klik in Azure op "Grant admin consent for [Uw Organisatie]" (of gebruik de knop "Admin Consent Verlenen" hierboven). Er verschijnt direct een groen vinkje bij alle regels. Hiermee hoeven collega's niet afzonderlijk om beheerderstoestemming te vragen en werkt zowel de agenda als de mailbox direct live!
diff --git a/auth/callback_microsoft.php b/auth/callback_microsoft.php index 4be4e25..d86525e 100644 --- a/auth/callback_microsoft.php +++ b/auth/callback_microsoft.php @@ -52,6 +52,13 @@ if (!empty($_GET['error'])) { exit; } +// 3b. Afhandeling van beheerderstoestemming (Admin Consent) +// Microsoft stuurt bij het /adminconsent endpoint geen state mee, enkel ?admin_consent=True&tenant=... +if (!empty($_GET['admin_consent'])) { + header('Location: /admin.php?success=' . urlencode('Beheerdersgoedkeuring voor uw organisatie is succesvol verleend! U en uw collega\'s kunnen nu direct hun Outlook agenda en e-mail koppelen via Fociz.')); + exit; +} + // 4. Valideer de state (via HMAC handtekening of fallback sessiestate) $expectedState = $_SESSION['ms_oauth_state'] ?? ''; unset($_SESSION['ms_oauth_state'], $_SESSION['ms_oauth_user_id']); @@ -61,12 +68,6 @@ if (!$stateUserId && (empty($receivedState) || empty($expectedState) || !hash_eq exit; } -// Afhandeling van beheerderstoestemming (Admin Consent) -if (!empty($_GET['admin_consent'])) { - header('Location: /admin.php?success=' . urlencode('Beheerdersgoedkeuring voor uw organisatie is succesvol verleend! U en uw collega\'s kunnen nu direct hun Outlook agenda koppelen via Mijn Profiel.')); - exit; -} - // 5. Autorisatiecode controleren $code = $_GET['code'] ?? ''; if (empty($code)) { -- 2.52.0