Unable to integrate Github Oauth via Omniauth
Summary
Attempting to sign in via GitHub or connect a GitHub account to an existing account simply takes the user back to the home page.
Steps to reproduce
- Create GitHub Oauth application with the settings outlined here: https://docs.gitlab.com/ce/integration/github.html
- Enable omniauth in gitlab.rb.
- Configure gitlab_rails as follows.
gitlab_rails['omniauth_providers'] = [{ "name" => "github", "app_id" => "Github Application's Client ID", "app_secret" => "Github Application's Client Secret", "args" => { "scope" => "user:email" } }]
- Reconfigure and restart GitLab
- Perform either of the following actions
- Attempt to log into GitLab with GitHub
- Click the GitHub entry's
connect
button at /profile/account when logged in with a local GitLab account
What is the current bug behavior?
Selecting the GitHub logo at the sign in screen or the GitHub connect
button in one's account settings takes one to the following path in the GitLab instance: ?error=redirect_uri_mismatch&error_description=The+redirect_uri+MUST+match+the+registered+callback+URL+for+this+application.&error_uri=https%3A%2F%2Fdeveloper.github.com%2Fv3%2Foauth%2F%23redirect-uri-mismatch&state=$state
The error_uri
parameter decodes to https://developer.github.com/apps/building-integrations/setting-up-and-registering-oauth-apps/.
Using /users/auth/github/callback
as the application callback causes it to display "You are already signed in" at the top of the screen after redirecting you to the root page if you use the connect
option, and displays "You need to sign in or sign up before continuing." when hit the GitHub logo at the sign in page.
What is the expected correct behavior?
The GitHub sign in logo should not be displayed at the GitLab instance's sign in screen, as I have not enabled allow_single_sign_on
and it makes no sense to give GitLab a handle to your GitHub account before it even knows what account it should link it to.
Selecting the GitHub connect
button in one's account settings should take one to the GitHub login page or GitHub's application permission approval page.
Results of GitLab environment info
Expand for output related to GitLab environment info
Version: 5.1.1 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
System information System: Ubuntu 16.04 Current User: git Using RVM: no Ruby Version: 2.3.3p222 Gem Version: 2.6.6 Bundler Version:1.13.7 Rake Version: 10.5.0 Redis Version: 3.2.5 Git Version: 2.13.0 Sidekiq Version:5.0.0 Go Version: go1.6.2 linux/amd64GitLab information Version: 9.3.5 Revision: 0c9ceb3 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: http://thewhoareyouperson.com:8083 HTTP Clone URL: http://thewhoareyouperson.com:8083/some-group/some-project.git SSH Clone URL: git@thewhoareyouperson.com:some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers: github
GitLab Shell Version: 5.1.1 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git 17:38:58 isavegas@GLaDOS ~ sudo gitlab-rake gitlab:check SANITIZE=true Checking GitLab Shell ...
GitLab Shell version >= 5.1.1 ? ... OK (5.1.1) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by git:root, or git:git? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... 4/5 ... ok 3/6 ... ok Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Access to /var/opt/gitlab/.ssh/authorized_keys: OK Send ping to redis server: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Reply by email ...
Reply by email is disabled in config/gitlab.yml
Checking Reply by email ... Finished
Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet) Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 4/5 ... yes 3/6 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.3 ? ... yes (2.3.3) Git version >= 2.7.3 ? ... yes (2.13.0) Active users: ... 3
Checking GitLab ... Finished
Possible fixes
If I am using the wrong callback path, this should be updated.
https://gitlab.com/gitlab-org/gitlab-ce/blob/c306e403fe3f74048488caac64b6c352e7ef5f3d/doc/integration/github.md#L22