RocketChat / RocketChat/Rocket.Chat
GitLab OAuth results in Error in OAuth Server: Failed to complete OAuth handshake
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description:
Using OAuth with a self-hosted GitLab instance results in Error in OAuth Server: Failed to complete OAuth handshake. Thus, my users cannot use their GitLab account to login on Rocket.Chat
Steps to reproduce:
- Go to Settings -> OAuth -> GitLab
- Use the following settings:
- OAuth Enabled: enabled
- GitLab URL: https://gitlab.<my.domain>/
- GitLab ID: ID from GitLab's OAuth applications (https://gitlab.<my.domain>/admin/applications)
- GitLab Secret Secret from GitLab's OAuth applications (https://gitlab.<my.domain>/admin/applications)
- Identity Path: /api/v4/user
- Merge Users: disabled
- GitLab Callback URL: https://chat.<my.domain>/_oauth/gitlab
- Save changes, logout, click on the GitLab button
- Window opens, pointing to: https://gitlab.<my.domain>/users/sign_in, fill in login details, click on Login
- GitLab shows authorize dialog (https://gitlab.<my.domain>/authorize), I click on authorize and the window closes
- Instead, Rocket.Chat shows an [undefined] error in the browser.
Expected behavior:
I expect to be able to authenticate my users against my self-hosted GitLab using OAuth.
Actual behavior:
Server returns a 404 not found: Error in OAuth Server: Failed to complete OAuth handshake with gitlab at https://gitlab.<my.domain>/oauth/token. failed [404] 404 page not found
Browser shows an error message: [undefined]
Server Setup Information:
- Version of Rocket.Chat Server: 3.13.1
- Operating System: Ubuntu 18.04.5 LTS
- Deployment Method: docker
- Number of Running Instances: 1
- DB Replicaset Oplog: enabled
- NodeJS Version: 12.21.0
- MongoDB Version: 4.4.5
Client Setup Information
- Desktop App or Browser Version: Google Chrome Version 89.0.4389.114 (Official Build) (64-bit)
- Operating System: Windows 10 Pro 19042.867
Additional context
My setup is behind a Traefik SSL proxy.
OAuth Application in GitLab:
- Callback URL: https://chat.<my.domain>/_oauth/gitlab
- Trusted: Y
- Confidential: Y
- Scopes: read_user
When I test with https://oauthdebugger.com/ everything works, POST https://gitlab.<my.domain>/oauth/token (with the correct key/values) results in
{
"access_token": "<token>",
"token_type": "Bearer",
"refresh_token": "<token>",
"scope": "read_user",
"created_at": 1618326157
}
Relevant logs:
Server:
{"line":"405","file":"oauth_server.js","message":"Error in OAuth Server: Failed to complete OAuth handshake with gitlab at https://gitlab.<my.domain>/oauth/token. failed [404] 404 page not found ","time":{"$date":1618321817770},"level":"warn"}
Brower:
{"isClientSafe":true,"message":"[undefined]","errorType":"Meteor.Error"}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report identifies oauth_server.js and the GitLab OAuth token endpoint; start by tracing the handshake from that file and reproducing the request against a self-hosted GitLab instance. Compare the request and endpoint behavior with the successful response shown from oauthdebugger.com, then add or update coverage for the failing flow. Done means GitLab login completes without the handshake or [undefined] errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- gitlab, typescript
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100