Since OAuth 2.0 itself does not natively support SLO, it must be supplemented with OIDC (OpenID Connect) logout mechanisms.
SLO ensures that when a user logs out of one application, they are automatically logged out of all applications using the same SSO session.
ADFS 2019 and Azure AD (Entra ID) support SLO using OIDC’s End Session Endpoint.
The web application must redirect the user to the IdP's logout endpoint and optionally provide an ID token to track the session.
Ensure your ADFS 2019 or Azure AD/Entra ID configuration supports OIDC-based logout.
ADFS 2019 Logout Endpoint:
https://adfs.example.com/adfs/oauth2/logout
Azure AD Logout Endpoint:
https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/logout
Modify your web application to handle logout by:
Redirecting the user to the IdP logout URL.
Passing the ID token (if required) to confirm session logout.
Redirecting the user to a post-logout landing page.
https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/logout ?post_logout_redirect_uri=https://yourapp.com/logout &id_token_hint={id_token}
https://adfs.example.com/adfs/oauth2/logout ?post_logout_redirect_uri=https://yourapp.com/logout &id_token_hint={id_token}
post_logout_redirect_uri: Specifies where the user should be redirected after logout.
id_token_hint (Optional): Helps the IdP identify which session to terminate.
Destroy the user session in your web app after logging out.
Clear session cookies, tokens, and authentication state.
Example (Node.js/Express):
app.get('/logout', (req, res) => { req.session.destroy(); // Destroy session res.clearCookie('session'); // Clear cookies res.redirect('https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/logout?post_logout_redirect_uri=https://yourapp.com/'); });
Some IdPs notify applications via front-channel logout.
Apps need to listen for a logout request and terminate local sessions.
Example Azure AD Front-Channel Logout URL:
https://yourapp.com/logout
Configure this URL in Azure AD Enterprise Application > Logout URL.
If your web app supports back-channel logout, listen for logout notifications from the IdP.
This requires storing OAuth session references and handling logout events.
Here’s how you can handle Single Logout (SLO) in a PHP web application when using Azure AD (Entra ID) or ADFS 2019 for OAuth 2.0 SSO.
Modify your logout.php script to:
Destroy the PHP session to log the user out locally.
Clear cookies and authentication tokens.
Redirect the user to the IdP logout URL (Azure AD or ADFS 2019).
logout.php<?php
session_start();
// Destroy session
session_destroy();
// Clear session cookies
setcookie(session_name(), '', time() - 3600, '/');
// Redirect to Azure AD/ADFS logout
$tenant_id = "your-tenant-id"; // Azure AD tenant ID $post_logout_redirect_uri = urlencode("https://yourapp.com/");
// For Azure AD $logout_url = "https://login.microsoftonline.com/$tenant_id/oauth2/v2.0/logout?post_logout_redirect_uri=$post_logout_redirect_uri";
// For ADFS 2019 (Uncomment the following line if using ADFS instead of Azure AD)
// $logout_url = "https://adfs.example.com/adfs/oauth2/logout?post_logout_redirect_uri=$post_logout_redirect_uri";
// Redirect to logout endpoint header("Location: $logout_url"); exit; ?>
In Azure Portal, go to Azure AD > Enterprise Applications.
Select your application and navigate to Properties.
Set Logout URL to https://yourapp.com/logout.php.
Open AD FS Management on your ADFS server.
Go to Application Groups > Your App > Web API.
Ensure OAuth logout endpoint is enabled.
Add https://yourapp.com/logout.php as a trusted logout URL.
Please authenticate to join the conversation.
Planned
💡 Feature Suggestions
About 1 year ago

John Lohr
Get notified by email when there are changes.
Planned
💡 Feature Suggestions
About 1 year ago

John Lohr
Get notified by email when there are changes.