Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to authenticate Desktop App through gitlab OAUTH2 Login since 9.1.x #2906

Closed
wech71 opened this issue Oct 30, 2023 · 31 comments · Fixed by #2907
Closed

Unable to authenticate Desktop App through gitlab OAUTH2 Login since 9.1.x #2906

wech71 opened this issue Oct 30, 2023 · 31 comments · Fixed by #2907

Comments

@wech71
Copy link

wech71 commented Oct 30, 2023

Summary

Since upgrade to Server 9.1.0 (and 9.1.1) it does no longer work to log in trough gitlab authentication (oauth2) to the desktop app.

After downgrade to 9.0.0 it works again.

Steps to reproduce

  1. Self-hosted Mattermost Server behind nginx reverse proxy on /subpath
  2. Open Windows Desktop app (5.4.0, 5.5.0 or 5.5.1 - makes no difference)
  3. Ensure to be logged out of Mattermost
  4. Klick "gitlab" on mattermost login page and notice difference in behaviour:
  • -> In 9.1.x The gitlab login page opens in an external browser window,
  • -> In 9.0.0 The gitlab login page opens inside the desktop app
  1. After logging in to gitl gitlab, offers the possibility to continue in the browser (wich works) or in the desktop app trough the mattermost: pseudo-protocol (mattermost://subdomain.domain.tld/chat/login/desktop?client_token=xxxx&server_token=yyyy)
  2. Klick Desktop App button

Expected behavior

Mattermost desktop app should be logged in and display the chat-channel

Observed behavior (that appears unintentional)

The "Channels" tab is being shown with white background and a gray hyperlink to subdomain.domain.tld/subpath, after reload with Ctrl+R the mattermost login page with username/password and the "gitlab" button (same as in Step 4) is being displayed.

Possible fixes

Workaround: Downgraded Server to 9.0.0

I could not find any dubious requests in the Mattermost Developer Tools or nginx reverse-proxy except some 401 errors like the request for
https://subdomain.domain.tld/subpath/api/v4/cloud/subscription/self-serve-status

@amyblais amyblais transferred this issue from mattermost/mattermost Oct 30, 2023
@devinbinnie
Copy link
Member

@wech71 Can you share which OS you are on? If it's Linux, can you share the distribution as well?

@wech71
Copy link
Author

wech71 commented Oct 30, 2023

Of course.

It's a linux ubuntu 20.04.6 (focal) server.

@wech71
Copy link
Author

wech71 commented Oct 30, 2023

ah, sorry, did you ask for the desktop-os? Its Windows 11, but it also happens on several computers including a RDP Terminal Server Session on a windows server 2016.

@devinbinnie
Copy link
Member

@wech71 Yes I meant the Desktop OS, all good :)
So what's supposed to happen is after you install the Desktop App it should register a protocol handler that accepts mattermost:// links.

So your users should see a prompt that has them open the Desktop App from their browser. Is that not happening?

@wech71
Copy link
Author

wech71 commented Oct 30, 2023

Yes, the protocol handler seems fine. When i click the mattermost:// link after logging in in the browser, the mattermost app reacts to the click, but I'm not logged in as expected and only see a white background (with a slight shadow of the mattermost-logo on it) and containing the gray text "subdomain.domain.tld/chat" ("chat" being the subpath).

When I press Ctrl+R the mattermost login page (with the "gitlab" buttton) appears again.

image

@devinbinnie
Copy link
Member

Yes, the protocol handler seems fine. When i click the mattermost:// link after logging in in the browser, the mattermost app reacts to the click, but I'm not logged in as expected and only see a white background (with a slight shadow of the mattermost-logo on it) and containing the gray text "subdomain.domain.tld/chat" ("chat" being the subpath).

When I press Ctrl+R the mattermost login page (with the "gitlab" buttton) appears again.

image

Are you able to provide logs from the Dev Tools? You can go to View > Developer Tools for Current Server and something should show up there. Looks like something is happening when the navigation happens.

@wech71
Copy link
Author

wech71 commented Oct 31, 2023

  • Developer Tools Console Ouput with Cache disabled, Ctrl+R
Preload initialized
index.js:150 Loading plugin jitsi, version 2.0.1
index.js:150 Loading plugin com.github.matterpoll.matterpoll, version 1.4.0
index.js:150 Loading plugin com.mattermost.plugin-create-ticket, version 0.1.0
index.js:150 Loading plugin com.mattermost.plugin-last-messages, version 0.1.0
index.js:150 Loading plugin com.mattermost.plugin-channel-export, version 1.0.0
index.js:136 Loaded plugin jitsi, version 2.0.1
index.js:136 Loaded plugin com.github.matterpoll.matterpoll, version 1.4.0
index.js:136 Loaded plugin com.mattermost.plugin-channel-export, version 1.0.0
jitsi_4ea03444a4a7ddb2_bundle.js:1     POST https://subdomain.domain.com/chat/plugins/jitsi/api/v1/config 401
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
r @ jitsi_4ea03444a4a7ddb2_bundle.js:1
doPost @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
r @ jitsi_4ea03444a4a7ddb2_bundle.js:1
loadConfig @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
r @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ index.js:16
e.initialize @ jitsi_4ea03444a4a7ddb2_bundle.js:1
(anonymous) @ index.js:171
s.onload @ index.js:135
load (async)
(anonymous) @ index.js:156
I @ index.js:117
(anonymous) @ index.js:82
v @ index.js:81
await in v (async)
(anonymous) @ root.tsx:296
(anonymous) @ root.tsx:427
await in (anonymous) (async)
componentDidMount @ root.tsx:433
mu @ react-dom.production.min.js:219
Li @ react-dom.production.min.js:259
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
zi @ react-dom.production.min.js:252
vi @ react-dom.production.min.js:243
(anonymous) @ react-dom.production.min.js:123
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Kl @ react-dom.production.min.js:123
F @ scheduler.production.min.js:16
w.port1.onmessage @ scheduler.production.min.js:12
index.js:136 Loaded plugin com.mattermost.plugin-create-ticket, version 0.1.0
index.js:136 Loaded plugin com.mattermost.plugin-last-messages, version 0.1.0
client4.js:2011     GET https://subdomain.domain.com/chat/api/v4/teams?page=0&per_page=200&include_total_count=false&exclude_policy_constrained=false 401
(anonymous) @ client4.js:2011
(anonymous) @ client4.js:2007
(anonymous) @ client4.js:657
(anonymous) @ teams.ts:135
(anonymous) @ index.js:16
(anonymous) @ redux.js:578
componentDidMount @ team_sidebar.tsx:150
mu @ react-dom.production.min.js:219
Li @ react-dom.production.min.js:259
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
zi @ react-dom.production.min.js:252
vi @ react-dom.production.min.js:243
(anonymous) @ react-dom.production.min.js:123
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Kl @ react-dom.production.min.js:123
ql @ react-dom.production.min.js:122
di @ react-dom.production.min.js:237
enqueueSetState @ react-dom.production.min.js:133
v.setState @ react.production.min.js:12
(anonymous) @ root.tsx:301
Promise.then (async)
(anonymous) @ root.tsx:297
(anonymous) @ root.tsx:427
await in (anonymous) (async)
componentDidMount @ root.tsx:433
mu @ react-dom.production.min.js:219
Li @ react-dom.production.min.js:259
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
zi @ react-dom.production.min.js:252
vi @ react-dom.production.min.js:243
(anonymous) @ react-dom.production.min.js:123
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Kl @ react-dom.production.min.js:123
F @ scheduler.production.min.js:16
w.port1.onmessage @ scheduler.production.min.js:12
client4.js:2011     GET https://subdomain.domain.com/chat/api/v4/cloud/subscription/self-serve-status 401
(anonymous) @ client4.js:2011
(anonymous) @ client4.js:2007
(anonymous) @ client4.js:1889
(anonymous) @ useCanSelfHostedExpand.ts:34
Fi @ react-dom.production.min.js:262
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Mi @ react-dom.production.min.js:261
vi @ react-dom.production.min.js:243
(anonymous) @ react-dom.production.min.js:123
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Kl @ react-dom.production.min.js:123
ql @ react-dom.production.min.js:122
di @ react-dom.production.min.js:237
enqueueSetState @ react-dom.production.min.js:133
v.setState @ react.production.min.js:12
(anonymous) @ root.tsx:301
Promise.then (async)
(anonymous) @ root.tsx:297
(anonymous) @ root.tsx:427
await in (anonymous) (async)
componentDidMount @ root.tsx:433
mu @ react-dom.production.min.js:219
Li @ react-dom.production.min.js:259
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
zi @ react-dom.production.min.js:252
vi @ react-dom.production.min.js:243
(anonymous) @ react-dom.production.min.js:123
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Kl @ react-dom.production.min.js:123
F @ scheduler.production.min.js:16
w.port1.onmessage @ scheduler.production.min.js:12
client4.js:2011     GET https://subdomain.domain.com/chat/api/v4/cloud/subscription/self-serve-status 401
(anonymous) @ client4.js:2011
(anonymous) @ client4.js:2007
(anonymous) @ client4.js:1889
(anonymous) @ useCanSelfHostedExpand.ts:34
Fi @ react-dom.production.min.js:262
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Mi @ react-dom.production.min.js:261
vi @ react-dom.production.min.js:243
(anonymous) @ react-dom.production.min.js:123
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Kl @ react-dom.production.min.js:123
ql @ react-dom.production.min.js:122
di @ react-dom.production.min.js:237
enqueueSetState @ react-dom.production.min.js:133
v.setState @ react.production.min.js:12
(anonymous) @ root.tsx:301
Promise.then (async)
(anonymous) @ root.tsx:297
(anonymous) @ root.tsx:427
await in (anonymous) (async)
componentDidMount @ root.tsx:433
mu @ react-dom.production.min.js:219
Li @ react-dom.production.min.js:259
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
zi @ react-dom.production.min.js:252
vi @ react-dom.production.min.js:243
(anonymous) @ react-dom.production.min.js:123
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Kl @ react-dom.production.min.js:123
F @ scheduler.production.min.js:16
w.port1.onmessage @ scheduler.production.min.js:12
DevTools failed to load source map: Could not load content for https://subdomain.domain.com/chat/plugins/jitsi/external_api.min.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE
7119.d3e201a523027592ffc5.css:1     GET https://subdomain.domain.com/chat/static/files/3c9c38b500586f2d033d.woff2 net::ERR_ABORTED 429
1815.e7ae6dc5aad14c446040.css:1     GET https://subdomain.domain.com/chat/static/files/1ab83b0759a47a9388de.woff2 net::ERR_ABORTED 429
7119.d3e201a523027592ffc5.css:1     GET https://subdomain.domain.com/chat/static/files/8a6c1879e3f4a4355b2e.woff2 net::ERR_ABORTED 429
7119.d3e201a523027592ffc5.css:1     GET https://subdomain.domain.com/chat/static/files/b2f7fa8bb26a2699b579.woff net::ERR_ABORTED 429
7119.d3e201a523027592ffc5.css:1     GET https://subdomain.domain.com/chat/static/files/6dc56ac51990a4e17b74.woff net::ERR_ABORTED 429
1815.e7ae6dc5aad14c446040.css:1     GET https://subdomain.domain.com/chat/static/files/f9a6a7af4b1ad2bde6c9.woff net::ERR_ABORTED 429
1815.e7ae6dc5aad14c446040.css:1     GET https://subdomain.domain.com/chat/static/files/80ecefff9d79b2837a96.ttf net::ERR_ABORTED 429
0.69f804ab84fccf2bf425.css:1     GET https://subdomain.domain.com/chat/static/files/0195d45bd4c7525e4a38.woff2 net::ERR_ABORTED 429
0.69f804ab84fccf2bf425.css:1     GET https://subdomain.domain.com/chat/static/files/08498623f6b3245d3eda.woff net::ERR_ABORTED 429
0.69f804ab84fccf2bf425.css:1     GET https://subdomain.domain.com/chat/static/files/b1330333eea7f47d4eb6.ttf net::ERR_ABORTED 429

=> login page is shown

  • Klicking gitlab => no new output in console, browser window (Edge) with gitlab login opens

  • Authorize access in browser window

  • Browser shows "You are now logged in. Click on Open Mattermost in the browser prompt to launch the desktop app", but seems to have already notified mattermost Desktop => new output in Mattermost Desktop Developer Console:

client4.js:2011     GET https://subdomain.domain.com/chat/api/v4/teams?page=0&per_page=200&include_total_count=false&exclude_policy_constrained=false 401
(anonymous) @ client4.js:2011
(anonymous) @ client4.js:2007
(anonymous) @ client4.js:657
(anonymous) @ teams.ts:135
(anonymous) @ index.js:16
(anonymous) @ redux.js:578
componentDidMount @ team_sidebar.tsx:150
mu @ react-dom.production.min.js:219
Li @ react-dom.production.min.js:259
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
zi @ react-dom.production.min.js:252
vi @ react-dom.production.min.js:243
(anonymous) @ react-dom.production.min.js:123
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Kl @ react-dom.production.min.js:123
ql @ react-dom.production.min.js:122
di @ react-dom.production.min.js:237
enqueueSetState @ react-dom.production.min.js:133
v.setState @ react.production.min.js:12
(anonymous) @ react-router.js:270
o @ history.js:155
(anonymous) @ history.js:173
notifyListeners @ history.js:172
C @ history.js:288
(anonymous) @ history.js:369
confirmTransitionTo @ history.js:145
push @ history.js:350
(anonymous) @ browser_history.tsx:33
postMessage (async)
(anonymous) @ VM386:642
emit @ VM385 sandbox_bundle:2
onMessage @ VM385 sandbox_bundle:2
client4.js:2011     GET https://subdomain.domain.com/chat/api/v4/cloud/subscription/self-serve-status 401
(anonymous) @ client4.js:2011
(anonymous) @ client4.js:2007
(anonymous) @ client4.js:1889
(anonymous) @ useCanSelfHostedExpand.ts:34
Fi @ react-dom.production.min.js:262
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Mi @ react-dom.production.min.js:261
vi @ react-dom.production.min.js:243
(anonymous) @ react-dom.production.min.js:123
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Kl @ react-dom.production.min.js:123
ql @ react-dom.production.min.js:122
di @ react-dom.production.min.js:237
enqueueSetState @ react-dom.production.min.js:133
v.setState @ react.production.min.js:12
(anonymous) @ react-router.js:270
o @ history.js:155
(anonymous) @ history.js:173
notifyListeners @ history.js:172
C @ history.js:288
(anonymous) @ history.js:369
confirmTransitionTo @ history.js:145
push @ history.js:350
(anonymous) @ browser_history.tsx:33
postMessage (async)
(anonymous) @ VM386:642
emit @ VM385 sandbox_bundle:2
onMessage @ VM385 sandbox_bundle:2
client4.js:2011     GET https://subdomain.domain/chat/api/v4/cloud/subscription/self-serve-status 401
(anonymous) @ client4.js:2011
(anonymous) @ client4.js:2007
(anonymous) @ client4.js:1889
(anonymous) @ useCanSelfHostedExpand.ts:34
Fi @ react-dom.production.min.js:262
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Mi @ react-dom.production.min.js:261
vi @ react-dom.production.min.js:243
(anonymous) @ react-dom.production.min.js:123
n.unstable_runWithPriority @ scheduler.production.min.js:18
Hl @ react-dom.production.min.js:122
Kl @ react-dom.production.min.js:123
ql @ react-dom.production.min.js:122
di @ react-dom.production.min.js:237
enqueueSetState @ react-dom.production.min.js:133
v.setState @ react.production.min.js:12
(anonymous) @ react-router.js:270
o @ history.js:155
(anonymous) @ history.js:173
notifyListeners @ history.js:172
C @ history.js:288
(anonymous) @ history.js:369
confirmTransitionTo @ history.js:145
push @ history.js:350
(anonymous) @ browser_history.tsx:33
postMessage (async)
(anonymous) @ VM386:642
emit @ VM385 sandbox_bundle:2
onMessage @ VM385 sandbox_bundle:2

Following the response text to first request
https://subdomain.domain.com/chat/api/v4/teams?page=0&per_page=200&include_total_count=false&exclude_policy_constrained=false

{"id":"api.context.session_expired.app_error","message":"Invalid or expired session, please login again.","detailed_error":"","request_id":"c4wu9pc6yj8m8brdz8fakhruze","status_code":401}

@devinbinnie
Copy link
Member

@wech71 Okay so if you're seeing the "You are now logged in" piece that means that the deep link was successful. If possible can you check the result of the request to the /login/desktop_token API? It would be under the network tab.

You might need to turn on "Preserve log" to make it work. What we're looking for is if the cookies are being set via a Set-Cookie header. You may not want to post the unsanitized result, but just a confirm that the Set-Cookie header is there should be enough.

@wech71
Copy link
Author

wech71 commented Nov 1, 2023

@devinbinnie hm, I don't see any /login/desktop_token neither in mattermost desktop, nor the web browser where the gitlab authentication occurs. Did you mean /login/desktop with the client and server token request params?

Both of them have "preserve log" and "disable cache" activated.

After clicking "Authorize" in gitlab in the browser, I can see the following requests:

@browser:
https://subdomain.domain.com/code/oauth/authorize
-> sets no cookies

https://subdomain.domain.com/chat/signup/gitlab/complete?code=15fxxxxxxxxxxxxxxxxxxxxxxxxxxxxx6d&state=eyJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx9
set-cookie "MMOAUTH=; Path=/chat; Max-Age=0; HttpOnly"
set-cookie "MMAUTHTOKEN=ktxxxxxxxxxxxxxxx; Path=/chat; Expires=Fri, 01 Dec 2023 06:34:39 GMT; Max-Age=2592000; HttpOnly; Secure"
set-cookie "MMUSERID=upxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; Path=/chat; Expires=Fri, 01 Dec 2023 06:34:39 GMT; Max-Age=2592000; Secure"
set-cookie "MMCSRF=wn7xxxxxxxxxxxxxx; Path=/chat; Expires=Fri, 01 Dec 2023 06:34:39 GMT; Max-Age=2592000; Secure"

https://subdomain.domain.com/chat/login/desktop?client_token=a6cxxxxxxxxxxxxxxxxxxxxxxxxxxxxx07b54f&server_token=mgxxxxxxxxxxxxxxxxxxxxxxxxxxxxx15ih
-> sets no cookies

I set a breakpoint to forwardToDesktopApp and it sets window.location to
mattermost://subdomain.domain.com/chat/login/desktop?client_token=a6cxxxxxxxxxxxxxxxxxxxxxxxxxxxxx07b54f&server_token=mgxxxxxxxxxxxxxxxxxxxxxxxxxxxxx15ih'

This then triggers the desktop app where the following requests happen:

@mattermost-desktop-app
https://subdomain.domain.com/chat/api/v4/teams?page=0&per_page=200&include_total_count=false&exclude_policy_constrained=false
401 -> sets no cookies

https://subdomain.domain.com/chat/api/v4/cloud/subscription/self-serve-status
401 -> sets no cookies

All three request use the following cookies in the requests:
rl_anonymous_id %22d00xxxxxx-xxxx-xxxx-xxxx-9axxxxxxf6ae%22
rl_user_id %22%22
preferred_language de
known_sign_in WHdsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxbmc9PQ%3D%3D--409xxxxxxxxxxxxxxxxxxxxxdb

As far as I understand, the mattermost: protocol runs another instance of the mattermost.exe with the specified url, but as this would be a different instance of the mattermost.exe, so I was thinking that the cookies are being set in the wrong instance. So I tried to set window.location in the running mattermost desktop app developers console to the mattermost:-Link, but this also does not produce any requests at all in the network tab, but setting it to https://subdomain.domain.com/chat/ instead does, so it works.

In fact setting it to anything 'https://subdomain.domain.com/chat/login[?/].*' does not trigger any reaction.

All test where made with Mattermost Desktop App 5.4.0 on Windows Terminal Server 2016

@devinbinnie
Copy link
Member

Thanks for the detail :)

So in the second instance case, we should be seeing something in the logs when it opens, see the function that does the second instance check here:

export function handleAppSecondInstance(event: Event, argv: string[]) {
    log.debug('handleAppSecondInstance', argv);

    // Protocol handler for win32
    // argv: An array of the second instance’s (command line / deep linked) arguments
    MainWindow.show();
    const deeplinkingURL = getDeeplinkingURL(argv);
    if (deeplinkingURL) {
        openDeepLink(deeplinkingURL);
    }
}

This is what should be handling the deep linking. Weirdly though, it looks like something is opening that URL, but it's not your Desktop App. Have you tried using v5.5.1 Desktop App?

@wech71
Copy link
Author

wech71 commented Nov 3, 2023

How can I debug the second app (the one started through mattermost:-Protocol)? - it immediately exits after processing the mattermost:// link, and I have no time to open the developer tools an this second instance. And running mattermost.exe without parameter also just activates the first (already running) instance and exists immediately.

I also just tried it wit the v5.5.1 app - unfortunately the problem persists.

@devinbinnie
Copy link
Member

@wech71 So it seems like it's working as intended as the second instance is popping up and doing something.

This is more than likely something on your server-side at this point, so I'm going to send this back over to the server repo to be investigated there.

@devinbinnie devinbinnie transferred this issue from mattermost/desktop Nov 3, 2023
@amyblais
Copy link
Member

amyblais commented Nov 3, 2023

@sei-jbooz
Copy link

sei-jbooz commented Nov 3, 2023

I am experiencing the same issue. I am running MM Enterprise 9.1.0. Desktop App version 5.5.1 on MacOS Sanoma 14.1 and Windows 10. This issue arose when I upgraded to MM 9.1.0

Edit: I should clarify that I am using OIDC Auth from a provider that is not GitLab.

@sei-jbooz
Copy link

I noticed that when running MM Server version 9.1.0, I was directed to my computer's default browser for login, then the attempted redirect back to the Desktop App didn't work.

When running MM Server version 9.0.0, the authentication workflow stays in the Desktop App - it loads up my auth provider's site within the Desktop App rather than opening a new tab in my web browser.

@wech71
Copy link
Author

wech71 commented Nov 4, 2023

@sei-jbooz: Just out of curiosity: Is your mattermost server instance also hostend on a subpath like mine or directly at the root level of the mattermost server?

@sei-jbooz
Copy link

My Mattermost and OIDC Provider are both hosted in a subpath on the domain.

@devinbinnie
Copy link
Member

devinbinnie commented Nov 6, 2023

Ah, so the subpath appears to be the culprit here. I can reproduce the issue on another subpath server.
Opened a ticket: MM-55317

@wiebel
Copy link
Contributor

wiebel commented Nov 8, 2023

The official create_desktop_file.sh contained in the linux package creates a Mattermost.desktop file missing:

  • MimeType=x-scheme-handler/mattermost
  • Exec=... %U

That should be fixed, no matter the root cause.

@devinbinnie
Copy link
Member

@wiebel Second bit is already done: #2896
The MimeType is missing though, is that something you'd be willing to add for us?

@devinbinnie
Copy link
Member

Transferred back to desktop repo as it turns out there was an issue with the app misinterpreting deep links for subpaths. PR is up to fix :)

@marjoleintamis
Copy link

I'm not sure if this is the same issue but I'm tagging onto it because I think it might be. I ran into a similar thing when trying to log in to a server via GitLab. Some specifics:

  • The server version is 9.2.2
  • Running Mattermost Desktop version 5.5.1 commit db8465b
  • Logging in refers me to the GitLab setup in Firefox where I'm already logged in via 2FA. The site refers me back to the Mattermost app, which gives me a blank screen with only the Channels tab and the server name on it. Clicking on the server name sends me back to the login page.
  • I also tried this in Chrome and Edge, where I had to log in fresh. Same result.
  • Ctrl-R also reloads to the login page.

Logs:

Preload initialized
index.js:150 Loading plugin jitsi, version 2.0.1
index.js:150 Loading plugin mattermost-standup, version 0.1.0
index.js:150 Loading plugin com.github.matterpoll.matterpoll, version 1.6.1
index.js:150 Loading plugin com.mattermost.calls, version 0.20.0
index.js:150 Loading plugin focalboard, version 7.11.4
index.js:136 Loaded plugin mattermost-standup, version 0.1.0
index.js:136 Loaded plugin jitsi, version 2.0.1
index.js:136 Loaded plugin com.github.matterpoll.matterpoll, version 1.6.1
index.js:136 Loaded plugin com.mattermost.calls, version 0.20.0
plugins/jitsi/api/v1/config:1     Failed to load resource: the server responded with a status of 401 ()
focalboard_bc5a129749169408_bundle.js:2 [1700033888.89] OctoClient baseURL: https://site.domain.nl/chat/plugins/focalboard
index.js:136 Loaded plugin focalboard, version 7.11.4
com.mattermost.calls_ed1c001e0ba11dd4_bundle.js:2 com.mattermost.calls: loading translations file for locale 'en'
api/v4/teams?page=0&per_page=200&include_total_count=false&exclude_policy_constrained=false:1     Failed to load resource: the server responded with a status of 401 ()
Metropolis-SemiBold.woff2:1     Failed to load resource: the server responded with a status of 404 ()
api/v4/teams?page=0&per_page=200&include_total_count=false&exclude_policy_constrained=false:1     Failed to load resource: the server responded with a status of 401 ()
api/v4/teams?page=0&per_page=200&include_total_count=false&exclude_policy_constrained=false:1     Failed to load resource: the server responded with a status of 401 ()
DevTools failed to load source map: Could not load content for https://site.domain.nl/chat/plugins/jitsi/external_api.min.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE

If this is a different issue, I can make a separate issue of it. Thanks!

@derzinn
Copy link

derzinn commented Nov 15, 2023

While we wait for an update, the workaround is to manually register the MIME type:

xdg-mime default com.mattermost.Desktop.desktop x-scheme-handler/mattermost

Tested on Fedora Workstation 39 with Mattermost Desktop Version 5.5.1 (Flatpak).

@wech71
Copy link
Author

wech71 commented Dec 4, 2023

Just a short feedback: After upgrading to Mattermost Desktop 5.6.0.RC1 and Mattermost Server 9.2.3 everything seems to work fine now :-)

@grisuthedragon
Copy link

I updated my installation from 8.1.x to 9.3.0 on the server side and using the 5.6.0 client on Linux ( Ubuntu 22.04 ) and we still ran into the same issue.

  • I am using mattermost on a subpath /mattermost via nginx reverse proxy.
  • Self hosted
  • oauth2 with Gitllab.
  • Desktop app from the *deb package.
  • Mime-Type registered as described by @derzinn

The desktop app redirects to the browser, where I can authenticate against Gitlab, but then I does not switch back to the app. So the fix in #2907 did not solve the problem properly.

@toscomfk
Copy link

We have the same problem as grisuthedragon ...
Server 9.3.0 (self hosted)
MM Desktop Client 5.6.0 (Problem also occurring with Client 5.5.0)
Ubuntu 22.04 and 20.04
Desktop App will not receive the Auth token from the external browser window
Browsers tested were Firefox and Chromium

@johnramsden
Copy link

I'm having the same issue, authentication works but redirection does not work back to the client.

MM 5.6.0
Server (selfhosted) 9.4.2

Tested chrome, firefox

@Leny1996
Copy link

Leny1996 commented Apr 2, 2024

@devinbinnie looks like this issue is still present, we're facing the same problem when using Gitlab Oauth2 setup

@ja11sop
Copy link

ja11sop commented May 14, 2024

Please reopen this issue as clearly it still persists. We now have failures now across our entire estate and across all platforms including Windows, Kubuntu, Manjaro and Debian on both Firefox and Chrome. We're contemplating ditching Mattermost after many good years since we can no longer use the desktop application.

MM 5.7.0
Server 9.5.0 (self hosted)
Gitlab Oauth2 for authentication - redirect to desktop application now never works

@marvinl1986
Copy link

This issue still persists.

@devinbinnie we still have this issue:

Client: MM 5.7.0-832 (Ubuntu 22.04)
Server 9.7.2 (self hosted)
Gitlab Oauth2 for authentication - redirect to desktop application does not work

@ToppDev
Copy link

ToppDev commented Jun 5, 2024

For me it worked with Firefox, but not with Chrome/Brave (they always open another browser window instead of Mattermost)

Client: Version 5.7.0 commit: e999e2c (NixOS unstable)
Server: 9.8.0 (self-hosted)
Gitlab Oauth2 authentication

Mime-Types: ~/.config/mimeapps.list

[Added Associations]
text/html=firefox.desktop
x-scheme-handler/chrome=firefox.desktop
x-scheme-handler/http=firefox.desktop
x-scheme-handler/https=firefox.desktop
x-scheme-handler/mattermost=Mattermost.desktop

[Default Applications]
text/html=firefox.desktop
x-scheme-handler/chrome=firefox.desktop
x-scheme-handler/http=firefox.desktop
x-scheme-handler/https=firefox.desktop
x-scheme-handler/mattermost=Mattermost.desktop

Mattermost.desktop

[Desktop Entry]
Name=Mattermost
Comment=Mattermost Desktop application for Linux
Exec="/nix/store/dgrlq4nh0k6z03a4ff81w75fb7ws2b9c-mattermost-desktop-5.7.0/bin/mattermost-desktop" %U
Terminal=false
Type=Application
MimeType=x-scheme-handler/mattermost
Icon=/nix/store/dgrlq4nh0k6z03a4ff81w75fb7ws2b9c-mattermost-desktop-5.7.0/share/mattermost-desktop/app_icon.png
Categories=Network;InstantMessaging;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.