Skip to content

AWS Cognito Logout does not work on Safari for Google

0

Hi,

I'm using the AWS Cognito Hosted UI login and logout functionality for Facebook and Google integration. Everything is working as expected on Google Chrome but I'm phasing issues on the Safari browser.

When using the https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html it logout the user fine on Google Chrome and when using the Login endpoint again the user is greeted with the Google select account screen. When doing the same on the Safari browser the user is never logged out and is logged in directly again. It looks like on Safari the cookies of Google and Cognito are not wiped correctly when using the logout on the Safari Browser. The issue occurs on IOS and on OSX.

Anyone has a solution for this?

asked 2 years ago401 views

1 Answer
1
The issue you're experiencing with AWS Cognito logout not working properly on Safari for Google authentication is a known problem. This behavior is likely due to how Safari handles cookies and sessions differently from other browsers like Google Chrome.

To address this issue, you can try the following approach:

1. Before redirecting to the Cognito `/logout` endpoint, first call the `/oauth2/revoke` endpoint to revoke the user's access and refresh tokens. This step helps ensure that the tokens are invalidated on the server-side.

2. After revoking the tokens, then redirect the user to the Cognito `/logout` endpoint as usual.

3. Consider setting shorter expiration times for ID tokens (e.g., 5 minutes) to reduce the risk window if tokens are compromised.

4. Implement additional client-side logout logic in your application to clear any local storage or state that contains user information.

5. If possible, redirect users to the Google account logout page after the Cognito logout process to ensure they're fully signed out of their Google account as well.

It's important to note that the Cognito logout process primarily invalidates the user's tokens on the server-side, and client-side actions like clearing cookies may have limitations, especially in Safari's more restrictive environment.

If the issue persists, you may need to implement a custom logout flow that takes into account Safari's specific behavior with cookies and sessions. This might involve using browser-specific detection and applying different logout strategies based on the user's browser.

Keep in mind that while this approach can help mitigate the issue, it may not completely resolve it in all scenarios due to the complexities of cross-browser authentication and session management.
  

Sources
AWS Cognitio Logout Bug? | AWS re:Post
How to logout from ALB-Cognito which is EC2 instance running React | AWS re:Post

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.