meshery: [bug] Inconsistent Logout Flow

Current Behavior

When a user logs out of Meshery then they experience an odd behavior where they see empty state in Meshery UI. In the process of logging out, even through the user session is cleared and specific token named cookie is removed the local storage, still they are not redirected to login screen. The above behavior is usually observed in playground environment. For the case of playground env, CORS errors are also observed in the console/network tab of the browser.

Expected Behavior

Once users logs out then they should be redirected to login screen.

Screenshots/Logs

Screenshot 2023-10-16 at 10 46 23 PM

To Reproduce

  1. Go to https://playground.meshery.io/
  2. Login with your credential
  3. Logout
  4. Go directly to https://playground.meshery.io/

Contributor Guides and Handbook

About this issue

  • Original URL
  • State: open
  • Created 8 months ago
  • Comments: 18 (18 by maintainers)

Most upvoted comments

@theBeginner86 this is the part of code that’s causing this bug -

https://github.com/meshery/meshery/blob/008a6e03e72485f793f6344a5d3eac507905a3e9/provider-ui/components/Provider.js#L77-L98

Actually we are making cross-origin request with credentials: include, but header in the response is wildcard , to fix this we need to specify the exact origin https://playground.meshery.io/ in the header of the response. This is something which will fix that CORS error, and probably that bug too.

If the proposed solution seems correct to you, then I would like to work on this issue 😃

@coder12git Good call. Thanks for bringing this up. Though that wouldn’t solve the current issue at hand. Because for the case of playground deployment, we never land on Provider’s page (as we have custom build that selects Meshery provider through an env variable that skips the Provider UI where users are given choice to select the providers). You can confirm this by checking the network tab while you are navigating to Playground.

There is a quick way to mimic Playground env locally by running Make target: https://github.com/meshery/meshery/blob/master/Makefile#L184 (To test your local/proposed changes)

The CORS issue is due to the fact that Meshery Server is trying to directly reach out to one of the Identity Servers of Remote Provider and it rejects the requests because it has been configured to only listen to the requests that originates from https://meshery.layer5.io. Screenshot 2023-10-21 at 4 25 26 PM

And this CORS issue is due to the logout bug. If we fix the logout issue then CORS issue would be auto-fixed

@theBeginner86 can i know how we are checking whether the user is authenticated or not before showing the dashboard component here -

https://github.com/meshery/meshery/blob/8941ee69ecbf874b8dff5c53948e736ea1dde07a/ui/pages/index.js#L16-L24

@coder12git We use this middleware to determine the user authentication status. https://github.com/meshery/meshery/blob/master/server/handlers/middlewares.go#L60 It introspects the user token and determines if it’s still valid or not. If not valid then it redirects to login screen.

@theBeginner86 can you please assign this issue to me and @Shiva953 , as we both are collaborating on this.

@coder12git I’ve created the thread, please check.

@coder12git I’m working on it since yesterday, but im still unable to relate the CORS Error source with the delay in having the login page, and the stateless screen in between. Maybe we can collaborate.

Okay, I am in let’s talk on slack. Can you create a thread on slack in #general or #meshery channel, and pin me, probably we can discuss there 😃

Seems reasonable @coder12git

Let’s see what @theBeginner86 says

@theBeginner86 this is the part of code that’s causing this bug - https://github.com/meshery/meshery/blob/008a6e03e72485f793f6344a5d3eac507905a3e9/provider-ui/components/Provider.js#L77-L98

Actually we are making cross-origin request with credentials: include, but header in the response is wildcard , to fix this we need to specify the exact origin https://playground.meshery.io/ in the header of the response. This is something which will fix that CORS error, and probably that bug too.

If the proposed solution seems correct to you, then I would like to work on this issue 😃

Thanks for jumping here, @Shiva953. 👍 Please keep your notes coming…

Also this only happens when we quickly go to the playground after logging out , and if we retry after some time it goes through the usual flow