RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.28k stars 10.45k forks source link

GitHub Enterprise OAuth fails on GHE 3.0.10 #23030

Open ngrande opened 3 years ago

ngrande commented 3 years ago

Description:

I have trouble configuring GitHub Enterprise OAuth Login with:

I have set it up as documented (created an OAuth App in GHE with the RC callback URL, configured the Client ID and Secret in RC). But it always fails with the following error:

Exception while invoking method 'login' Error: Failed to fetch identity from github_enterprise at https://github.ruv.de/api/v3/user. failed [400] {"message":"Must specify access token via Authorization header","documentation_url":"https://docs.github.com/enterprise/3.0/v3/#oauth2-token-sent-in-a-header"} at CustomOAuth.getIdentity (app/custom-oauth/server/custom_oauth_server.js:197:18) at Object.handleOauthRequest (app/custom-oauth/server/custom_oauth_server.js:206:26) at OAuth._requestHandlers.<computed> (packages/oauth2/oauth2_server.js:10:33) at middleware (packages/oauth/oauth_server.js:170:5) at /app/bundle/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40

We have a second RocketChat instance running in our to-be-deprecated K8s cluster which also uses our GHE 3.0.10 for the OAuth login which succeeds without problems. I can not find any differences between my freshly setup RocketChat and the old instance.

Steps to reproduce:

  1. Install GHE 3.0.10
  2. Install RocketChat 3.17.1
  3. Create a GHE Application for RocketChat (with the CallBack URL from RocketChat)
  4. Configure the GHE OAuth Login in RocketChat (with the GHE App Client ID and Secret)
  5. Perform a GitHub Login

Expected behavior:

User authorizes the RocketChat App to get the User Info from GHE. User gets a new account if no account exists yet. User can use RocketChat.

Actual behavior:

User authorizes RocketChat App to get the User Info from GHE. RocketChat fails retrieving the User Info from GHE.

Server Setup Information:

Client Setup Information

Additional context

Log Level set to 2

Relevant logs:

Server: Exception while invoking method 'login' Error: Failed to fetch identity from github_enterprise at https://github.ruv.de/api/v3/user. failed [400] {"message":"Must specify access token via Authorization header","documentation_url":"https://docs.github.com/enterprise/3.0/v3/#oauth2-token-sent-in-a-header"} at CustomOAuth.getIdentity (app/custom-oauth/server/custom_oauth_server.js:197:18) at Object.handleOauthRequest (app/custom-oauth/server/custom_oauth_server.js:206:26) at OAuth._requestHandlers.<computed> (packages/oauth2/oauth2_server.js:10:33) at middleware (packages/oauth/oauth_server.js:170:5) at /app/bundle/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40

Client reports "Internal server error" {"isClientSafe":true,"error":500,"reason":"Internal server error","message":"Internal server error [500]","errorType":"Meteor.Error"}

mch1307 commented 3 years ago

Did you manage to fix your issue, having same kind of issue after an upgrade of the gtihub instance.

simon-weimann commented 2 years ago

Unfortunately, I have to bring this up again, as we were affected by this with the update to Github Enterprise version 3.4.1

As stated in the official changelog from Github, starting with version 3.4 they have removed the api authentication using query parameters, that has been marked deprecated previously.

Unfortunately, Rocket.Chat still uses this mechanism up to date (4.6.3).

However the fix should be easy setting tokenSentVia to header in https://github.com/RocketChat/Rocket.Chat/blob/c345f77aa5a7186831e684a8f44682490b079463/apps/meteor/app/github-enterprise/lib/common.js#L10

We built a custom version of Rocket.Chat based on 4.6.3 with the above mentioned changed and could solve this issue.

I will try and contribute this fix