- Newest
- Most votes
- Most comments
Understanding SAML Single Sign-Out with Amazon Cognito
When using Amazon Cognito with a SAML identity provider (IdP) like Akamai Enterprise Application Access, the behavior you're experiencing is related to how SAML single sign-out (SLO) works with Cognito.
Current Behavior Analysis
The issue you're experiencing occurs because:
- When a user's Cognito session cookie expires (after 1 hour in your case), Cognito no longer has context about the user's SAML session.
- Without an active Cognito session, when a logout is attempted, Cognito cannot properly direct the SAML logout request to your IdP's SLO endpoint.
How SAML Single Sign-Out Works in Cognito
When a user with an active SAML session is directed to the Cognito /logout endpoint, Cognito sends a signed SAML logout request to the IdP's Single Logout Service endpoint specified in the IdP metadata. The IdP then processes this request, terminates the session, and sends a LogoutResponse back to Cognito's saml2/logout endpoint.
For this flow to work properly, Cognito needs to know:
- The user has an active SAML session
- Which IdP to send the logout request to
- The session information to include in the logout request
Mitigation Strategies
- Direct IdP Logout:
Instead of relying solely on Cognito's
/logoutendpoint, implement a direct logout to both systems. When a user clicks logout, your application can:
- Call Cognito's logout endpoint
- Also directly call your IdP's logout endpoint
-
Shorter Session Duration: Align the session timeout values between Cognito and your IdP to minimize the window where one system has an active session while the other doesn't.
-
Client-Side Session Management: Implement client-side tracking of session status. When detecting a Cognito session expiration, proactively redirect the user to the IdP logout endpoint.
-
Custom Logout Flow: Implement a custom logout flow where your application first checks if the Cognito session is active:
- If active, use the standard Cognito logout flow
- If expired, directly redirect to the IdP's logout endpoint
- Application Load Balancer Integration: If you're using an Application Load Balancer (ALB), ensure your application sets the expiry to -1 for all authentication cookies during logout and redirects to the IdP logout endpoint.
The most reliable approach would be a combination of strategies 1 and 4, where your application handles both the Cognito logout and direct IdP logout, with logic to determine which path to take based on the Cognito session status.
Sources
Signing out SAML users with single sign-out - Amazon Cognito
The managed login sign-out endpoint: /logout - Amazon Cognito
Authenticate users using an Application Load Balancer - Elastic Load Balancing
Identity provider and relying party endpoints - Amazon Cognito
answered 10 months ago
Relevant content
asked 4 years ago
- AWS OFFICIALUpdated 6 months ago

The following countermeasures have all been considered and found to be infeasible:
Direct IdP Logout: It is not possible to send a direct logout request from Cognito to Akamai because the logout information for Akamai held by Cognito cannot be obtained. Therefore, the 1st, 3rd, 4th, and 5th solutions proposed in the
Mitigation Strategiesare infeasible.Shorter Session Duration: The session duration for Cognito is 1 hour, and for Akamai it is 2 hours, and neither can be changed. The 2nd solution proposed in the
Mitigation Strategiesis infeasible.Given these constraints, could you please advise if there are any other effective countermeasures?