mattermost / desktop

Mattermost Desktop application for Windows, Mac and Linux
Apache License 2.0
2.03k stars 829 forks source link

[Bug]: Desktop app hangs after user login through simulated Gitlab SSO. #2895

Closed WestFarmer closed 1 year ago

WestFarmer commented 1 year ago

Checks before filing an issue

Mattermost Desktop Version

5.5.1

Operating System

Fedora 37

Mattermost Server Version

9.1.0

Steps to reproduce

  1. install keycloak
  2. create a realm
  3. create a client
  4. config client add mappers to simulate gitlab
  5. add a user
  6. open desktop app to login with user created in step 5

Expected behavior

desktop load main UI, after user login in browser

Observed behavior

desktop app hangs at:

图片

Please Note: while in browser, I can click Open Mattermost in your browser, then use Mattermost as a user signed in..

Log Output

nothing useful:

[2023-10-25 16:08:46.161] [debug] [ViewManager] focusCurrentView
[2023-10-25 16:08:46.162] [debug] [ServerDropdownView] handleClose
[2023-10-25 16:08:46.163] [debug] [DownloadsDropdown...] handleClose
[2023-10-25 16:08:46.164] [debug] [DownloadsDropdown...] handleClose
[2023-10-25 16:08:46.165] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenuItem {}
[2023-10-25 16:08:46.166] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 16:08:46.167] [debug] [DownloadsDropdown...] handleClose
[2023-10-25 16:08:46.167] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenuItem {}
[2023-10-25 16:08:46.168] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 16:08:46.169] [debug] [ServerDropdownView] handleClose
[2023-10-25 16:08:46.170] [debug] [DownloadsDropdown...] handleClose
[2023-10-25 16:08:46.170] [debug] [DownloadsDropdown...] handleClose
[2023-10-25 16:08:46.171] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenuItem {}
[2023-10-25 16:08:46.171] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 16:08:46.172] [debug] [DownloadsDropdown...] handleClose
[2023-10-25 16:08:46.173] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenuItem {}
[2023-10-25 16:08:46.173] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 16:08:51.594] [debug] [ViewManager] focusCurrentView
[2023-10-25 16:08:51.883] [debug] [ServerDropdownView] handleClose
[2023-10-25 16:08:51.884] [debug] [DownloadsDropdown...] handleClose
[2023-10-25 16:08:51.884] [debug] [DownloadsDropdown...] handleClose
[2023-10-25 16:08:51.885] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenuItem {}
[2023-10-25 16:08:51.885] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 16:08:53.949] [debug] [App.Utils] flushCookiesStore
[2023-10-25 16:08:53.950] [debug] [ViewManager] handleSetCurrentViewBounds { x: 0, y: 60, width: 2290, height: 1240 }
[2023-10-25 16:08:53.951] [debug] [ModalManager] handleResizeModal {
  bounds: { x: 0, y: 60, width: 2290, height: 1240 },
  modalQueueLength: 0
}
[2023-10-25 16:08:53.951] [debug] [App] [ServerViewState] getCurrentServer
[2023-10-25 16:08:53.952] [debug] [DownloadsDropdown...] updateWindowBounds
[2023-10-25 16:08:53.952] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenu
[2023-10-25 16:08:53.952] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenuItem {}
[2023-10-25 16:08:53.953] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 16:08:53.953] [debug] [DownloadsDropdown...] updateWindowBounds
[2023-10-25 16:08:53.954] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 16:08:54.073] [debug] [App.Initialize] UserActivityMonitor.on(status) { userIsActive: true, idleTime: 0, isSystemEvent: false }
[2023-10-25 16:09:54.141] [debug] [App.Initialize] UserActivityMonitor.on(status) { userIsActive: true, idleTime: 2, isSystemEvent: false }
[2023-10-25 16:10:54.205] [debug] [App.Initialize] UserActivityMonitor.on(status) { userIsActive: true, idleTime: 2, isSystemEvent: false }


### Additional Information

broswer version: google chrome 118.0.5993.88
devinbinnie commented 1 year ago

@WestFarmer So for the external SSO to work, you should be seeing something in the debug logs that says new-window. If you're not that would mean that the login is not opening correctly.

With debug on can you confirm that you're not seeing that? If not, are there any modifications made to your server to change the way login works?

Nayruden commented 1 year ago

We are also seeing the same issue in our environment, Desktop 5.5.1, server 9.1.0. We do get new-window in the debug log, though.

devinbinnie commented 1 year ago

We are also seeing the same issue in our environment, Desktop 5.5.1, server 9.1.0. We do get new-window in the debug log, though.

Can you post your logs for me? If there's sensitive information you can DM them to me on community.mattermost.com @devinbinnie

Nayruden commented 1 year ago

Here's our log with the URLs scrubbed. We did have to register the matermost:// URL handler with xdg-mime default Mattermost.desktop x-scheme-handler/mattermost as well. We're on Ubuntu 22.04

[2023-10-25 09:23:18.574] [debug] [ServerManager] [318af5c4-cb22-484...] getOrderedTabsForServer
[2023-10-25 09:23:18.576] [debug] [WebContentsEventM...] [c92177c1-e3e4-430...] [Jeremy] [TAB_MESSAGING] did-start-navigation https://chat.company.com/login/desktop
[2023-10-25 09:23:18.579] [debug] [WebContentsEventM...] [c92177c1-e3e4-430...] [Jeremy] [TAB_MESSAGING] new-window https://chat.company.com/oauth/gitlab/login?desktop_token=2fbba720d9a3bc7ab19ba2d519712919be77ad752e6a31fbb8f35e55d122d172
[2023-10-25 09:23:18.579] [debug] [ServerManager] [318af5c4-cb22-484...] getOrderedTabsForServer
[2023-10-25 09:23:18.812] [debug] [App.Utils] flushCookiesStore
[2023-10-25 09:23:18.813] [debug] [ViewManager] handleSetCurrentViewBounds { x: 70, y: 396, width: 1614, height: 958 }
[2023-10-25 09:23:18.813] [debug] [ModalManager] handleResizeModal {
  bounds: { x: 70, y: 396, width: 1614, height: 958 },
  modalQueueLength: 0
}
[2023-10-25 09:23:18.814] [debug] [App] [ServerViewState] getCurrentServer
[2023-10-25 09:23:18.814] [debug] [DownloadsDropdown...] updateWindowBounds
[2023-10-25 09:23:18.815] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenu
[2023-10-25 09:23:18.815] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenuItem {}
[2023-10-25 09:23:18.816] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 09:23:18.816] [debug] [DownloadsDropdown...] updateWindowBounds
[2023-10-25 09:23:18.816] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 09:23:21.837] [error] Logger Log level set to: info
[2023-10-25 09:23:21.970] [error] Logger Log level set to: debug
[2023-10-25 09:23:21.970] [debug] [App.Config] handleConfigUpdate
[2023-10-25 09:23:21.971] [debug] [App.Utils] handleUpdateMenuEvent
[2023-10-25 09:23:21.972] [debug] [DownloadsManager] hasDownloads
[2023-10-25 09:23:21.972] [debug] [ServerManager] getOrderedServers
[2023-10-25 09:23:21.975] [debug] [ServerManager] getOrderedServers
[2023-10-25 09:23:21.979] [debug] [App.App] handleAppSecondInstance [
  '/opt/mattermost/mattermost-desktop',
  '--allow-file-access-from-files',
  '--enable-sandbox'
]
[2023-10-25 09:23:21.982] [debug] [ViewManager] handleSetCurrentViewBounds { x: 70, y: 396, width: 1614, height: 958 }
[2023-10-25 09:23:21.982] [debug] [ModalManager] handleResizeModal {
  bounds: { x: 70, y: 396, width: 1614, height: 958 },
  modalQueueLength: 0
}
[2023-10-25 09:23:21.982] [debug] [App] [ServerViewState] getCurrentServer
[2023-10-25 09:23:21.983] [debug] [DownloadsDropdown...] updateWindowBounds
[2023-10-25 09:23:21.983] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenu
[2023-10-25 09:23:21.983] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenuItem {}
[2023-10-25 09:23:21.983] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 09:23:21.984] [debug] [DownloadsDropdown...] updateWindowBounds
[2023-10-25 09:23:21.984] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 09:23:21.984] [debug] [ViewManager] focusCurrentView
[2023-10-25 09:23:22.409] [warn]  [App.Initialize] There was an error while trying to download the dictionary definitions for en-US, spellchecking might not work properly.
[2023-10-25 09:23:23.440] [debug] [App.Utils] flushCookiesStore
[2023-10-25 09:23:23.440] [debug] [ViewManager] handleSetCurrentViewBounds { x: 70, y: 396, width: 1614, height: 958 }
[2023-10-25 09:23:23.441] [debug] [ModalManager] handleResizeModal {
  bounds: { x: 70, y: 396, width: 1614, height: 958 },
  modalQueueLength: 0
}
[2023-10-25 09:23:23.441] [debug] [App] [ServerViewState] getCurrentServer
[2023-10-25 09:23:23.441] [debug] [DownloadsDropdown...] updateWindowBounds
[2023-10-25 09:23:23.441] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenu
[2023-10-25 09:23:23.442] [debug] [DownloadsDropdown...] updateDownloadsDropdownMenuItem {}
[2023-10-25 09:23:23.442] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 09:23:23.442] [debug] [DownloadsDropdown...] updateWindowBounds
[2023-10-25 09:23:23.442] [debug] [DownloadsDropdown...] updateDownloadsDropdown
[2023-10-25 09:23:39.801] [debug] [ViewManager] handleReactAppInitialized c92177c1-e3e4-4306-aede-14d1209051f1
[2023-10-25 09:23:39.832] [debug] [App] [ServerViewState] getCurrentServer
[2023-10-25 09:23:39.841] [debug] [App] [ServerViewState] getCurrentServer
[2023-10-25 09:23:40.441] [debug] [App] [ServerViewState] getCurrentServer
[2023-10-25 09:23:48.578] [debug] [App] [ServerViewState] getCurrentServer
[2023-10-25 09:24:10.413] [debug] [App.Initialize] UserActivityMonitor.on(status) { userIsActive: true, idleTime: 0, isSystemEvent: false }
devinbinnie commented 1 year ago

Here's our log with the URLs scrubbed. We did have to register the matermost:// URL handler with xdg-mime default Mattermost.desktop x-scheme-handler/mattermost as well. We're on Ubuntu 22.04

Yep, this all looks like normal Desktop App behaviour to me, and it doesn't look like it's being blocked by anything. Do you have a mime handler for http/https setup as well? At this point I would guess that the browser isn't being opened for some reason.

Nayruden commented 1 year ago

The browser (Chrome) is being opened correctly. The OAuth authorization prompt is opened for Mattermost's access request. After performing the GitLab authorization, we see the "You are now logged in" page from the Mattermost server inside Chrome. Then xdg-open is called from Chrome (sample xdg-open URL: mattermost://chat.company.com/login/desktop?client_token=73d214539204976baaf3acfcd818476c4f9b7c8b18a4587a40fad936e690f728&server_token=phgo11qn9h7swxgnw67urnbr5u1kjxdug757n6azyocoq4f59yp71onyef4b47ca) which brings the Mattermost client back to focus. However, nothing changes within the Mattermost client (it still says "Redirecting to browser...").

The logs I posted above capture the entire sequence of events from opening Chrome all the way through to Mattermost regaining focus after the xdg-open call.

devinbinnie commented 1 year ago

@Nayruden Okay that's a different issue than what the OP had posted, your issue is happening after the user has logged in and the browser is trying to link back to the Mattermost app.

Looking further down into the logs, it looks like you might have your xdg misconfigured:

[2023-10-25 09:23:21.979] [debug] [App.App] handleAppSecondInstance [
  '/opt/mattermost/mattermost-desktop',
  '--allow-file-access-from-files',
  '--enable-sandbox'
]

It looks like it's opening Mattermost, but not providing the link from Chrome in the arguments. Normally our app when installed via package manager should set up a .desktop file which appends any arguments from the command line. You may need to revisit your configuration.

Nayruden commented 1 year ago

This is the installer from 5.5.1 -- is something misconfigured here? https://github.com/mattermost/desktop/blob/v5.5.1/src/assets/linux/create_desktop_file.sh

#!/bin/sh
set -e
WORKING_DIR=`pwd`
THIS_PATH=`readlink -f $0`
cd `dirname ${THIS_PATH}`
FULL_PATH=`pwd`
cd ${WORKING_DIR}
cat <<EOS > Mattermost.desktop
[Desktop Entry]
Name=Mattermost
Comment=Mattermost Desktop application for Linux
Exec="${FULL_PATH}/mattermost-desktop"
Terminal=false
Type=Application
Icon=${FULL_PATH}/app_icon.png
Categories=Network;InstantMessaging;
EOS
chmod +x Mattermost.desktop
devinbinnie commented 1 year ago

This is the installer from 5.5.1 -- is something misconfigured here? https://github.com/mattermost/desktop/blob/v5.5.1/src/assets/linux/create_desktop_file.sh

#!/bin/sh
set -e
WORKING_DIR=`pwd`
THIS_PATH=`readlink -f $0`
cd `dirname ${THIS_PATH}`
FULL_PATH=`pwd`
cd ${WORKING_DIR}
cat <<EOS > Mattermost.desktop
[Desktop Entry]
Name=Mattermost
Comment=Mattermost Desktop application for Linux
Exec="${FULL_PATH}/mattermost-desktop"
Terminal=false
Type=Application
Icon=${FULL_PATH}/app_icon.png
Categories=Network;InstantMessaging;
EOS
chmod +x Mattermost.desktop

I think the Exec line needs to read like this: Exec="${FULL_PATH}/mattermost-desktop" %U

If the above script isn't including that I'll have to make a change to it.

Nayruden commented 1 year ago

That change fixed it! We'll implement this workaround until it's fixed upstream; thank you!

WestFarmer commented 1 year ago

@devinbinnie sorry for late reply, I am in UTC+8 I installed by tar ball, then manually created a desktop entry :

[Desktop Entry]
Name=MatterMost
Exec=/home/ggfan/1-install/mattermost-desktop-5.5.1-linux-x64/mattermost-desktop
Comment=
Terminal=false
Icon=/home/ggfan/1-install/mattermost-desktop-5.5.1-linux-x64/app_icon.png
Type=Application

also tried appended %U, but still not work for me.

do I need to register xdg like @Nayruden mentioned ?

xdg-mime default Mattermost.desktop x-scheme-handler/mattermost

for this to work , do I need Mattermost.desktop in %PATH ?

WestFarmer commented 1 year ago

@devinbinnie switched to RPM, now it works, but for generic linux install with tar ball, maybe the docs need improvement.

devinbinnie commented 1 year ago

Thanks, we'll look into it. Closing as completed.

sepastian commented 7 months ago

I'm using the AppImage, the problem still persists for me.

During login, Mattermost redirects to the browser, I login with Gitlab successfully, then the redirect back to Mattermost fails, as described above.

How do I correctly configure xdg-open when using the AppImage version of Mattermost in Debian 6.6.15-2?

devinbinnie commented 7 months ago

@sepastian We generally just recommend running the create_desktop_file.sh script. For xdg-open I think you just want to associate the mattermost protocol/mime-type to wherever AppImage dropped the executable.