davido / gerrit-oauth-provider

OAuth2 authentication provider for Gerrit Code Review. Please upload changes for review to: https://gerrit-review.googlesource.com/#/admin/projects/plugins/oauth
Apache License 2.0
140 stars 84 forks source link

Issues with GitLab OAuth #133

Closed minz1 closed 4 years ago

minz1 commented 4 years ago

The first issue I've been having is that the URL isn't properly being re-directed to GitLab. The URL is being appended to the end like this:

http://192.168.88.181:8080/login/gitlab.com/oauth/authorize?client_id=91d7ffcd38babcf71163725f1dd5a212994d6cd4ced022e6e4d9575f3d036d25&response_type=code&redirect_uri=http://192.168.88.181:8080/oauth&state=6FSvwAZZC9Ebz25vgzY8R-qruwMVnWdafCqoGv3kxV4

Rather than this:

gitlab.com/oauth/authorize?client_id=91d7ffcd38babcf71163725f1dd5a212994d6cd4ced022e6e4d9575f3d036d25&response_type=code&redirect_uri=http://192.168.88.181:8080/oauth&state=6FSvwAZZC9Ebz25vgzY8R-qruwMVnWdafCqoGv3kxV4

Also, when I cut and paste the appended URL into the browser, an exception is thrown and "Server Error" is displayed in plaintext on the page.

For reference, here is my gerrit.config just in case it's needed to properly debug. I'm running Gerrit 3.0.3 on an Ubuntu 18.04 VM.

davido commented 4 years ago

That's strange. Can you pass auth.type = OAUTH? It would also be good to increase the log level to debug. I don't use GitLab, so I cannot help to further investigate this issue.

minz1 commented 4 years ago

Okay. I've done that. a similar looking issue occurs when passing auth.type = OAUTH. This is what the URL looks like now:

http://192.168.88.181:8080/login/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/gitlab.com/oauth/authorize?client_id=91d7ffcd38babcf71163725f1dd5a212994d6cd4ced022e6e4d9575f3d036d25&response_type=code&redirect_uri=http://192.168.88.181:8080/oauth&state=rF1Wi18spa0Lhl03KxxxKEpLASSt0iytNlLnqAvaeUk

Firefox has an error saying "The page isn't redirecting properly." After copy+pasting just gitlab.com/oauth/authorize?client_id=91d7ffcd38babcf71163725f1dd5a212994d6cd4ced022e6e4d9575f3d036d25&response_type=code&redirect_uri=http://192.168.88.181:8080/oauth&state=rF1Wi18spa0Lhl03KxxxKEpLASSt0iytNlLnqAvaeUk, I get the same "Server Error". Here is the log.

davido commented 4 years ago

Looking again into your gerrit.config: your root-url is wrong: root-url = gitlab.com. The URL must be absolute URL. Changing it to: root-url = https://gitlab.com should fix your problem.

davido commented 4 years ago

To avoid similar misconfiguration errors in future I added this check: [1].

[1] https://gerrit-review.googlesource.com/c/plugins/oauth/+/243350