Stsosz
By:
Stsosz

Multiple oAuth providers in Gitlab

March 31, 2015 3.1k views
One-Click Install Apps Git Ubuntu

I have been using Gitlab for a while now and, judging from their login page, which runs gitlab, I should be able to use multiple omniauth providers. It seems, however, that i cannot. I have been trying this for several hours, without any result.

My gitlab.rb:

# General Settings
external_url "https://gitlab.stsosz.io"

# Ruby on Rails Settings
gitlab_rails['gitlab_email_from'] = "gitlab@stsosz.io"
gitlab_rails['gitlab_support_email'] = "support@stsosz.io"

## TImezone Setting
gitlab_rails['time_zone'] = 'EST'

## Backup Options
gitlab_rails['backup_keep_time'] = 604800

## Sign-in Page Options
gitlab_rails['gitlab_signup_enabled'] = true
gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = true
gitlab_rails['omniauth_block_auto_created_users'] = false

gitlab_rails['omniauth_providers'] = [
    {
      "name" => "github",
      "app_id" => "Removed for Security",
      "app_secret" => "Removed for Security",
      "url" => "https://github.com/",
      "args" => { "scope" => "user:email"}
    }
    {
      "name" => "google_oauth2",
      "app_id" => "Removed for Security",
      "app_secret" => "Removed for Security",
      "args" => { "access_type" => "offline", "approval_prompt" => "" }
    }
]

# Nginx Settings
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/ssl-gitlab.unified.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/ssl-gitlab.key"
# nginx['custom_nginx_config'] = "include /etc/gitlab/nginx_custom/stsosz_io.conf;"

# Unicorn Settings
unicorn['worker_processes'] = 5

Here is the output of sudo gitlab-ctl reconfigure

[2015-03-31T16:20:02-04:00] INFO: Forking chef instance to converge...
[2015-03-31T16:20:02-04:00] INFO: *** Chef 11.12.2 ***
[2015-03-31T16:20:02-04:00] INFO: Chef-client pid: 11104
[2015-03-31T16:20:03-04:00] INFO: Setting the run_list to ["recipe[gitlab]"] from CLI options
[2015-03-31T16:20:03-04:00] INFO: Run List is [recipe[gitlab]]
[2015-03-31T16:20:03-04:00] INFO: Run List expands to [gitlab]
[2015-03-31T16:20:03-04:00] INFO: Starting Chef Run for Europa
[2015-03-31T16:20:03-04:00] INFO: Running start handlers
[2015-03-31T16:20:03-04:00] INFO: Start handlers complete.
^[[0m
================================================================================^[[0m
^[[31mRecipe Compile Error in /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb^[[0m
================================================================================^[[0m

^[[0m
SyntaxError^[[0m
-----------^[[0m
/etc/gitlab/gitlab.rb:37: syntax error, unexpected {, expecting ']'
/etc/gitlab/gitlab.rb:43: syntax error, unexpected ']', expecting end-of-input^[[0m

^[[0m
Cookbook Trace:^[[0m
---------------^[[0m
  /opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb:32:in `from_file'^[[0m

^[[0m
Relevant File Content:^[[0m
----------------------^[[0m
/opt/gitlab/embedded/cookbooks/gitlab/recipes/default.rb:

 25:    group "root"
 26:    mode "0775"
 27:    action :nothing
 28:  end.run_action(:create)
 29:
 30:  Gitlab[:node] = node
 31:  if File.exists?("/etc/gitlab/gitlab.rb")
 32>>   Gitlab.from_file("/etc/gitlab/gitlab.rb")
 33:  end
 34:  node.consume_attributes(Gitlab.generate_config(node['fqdn']))
 35:
 36:  if File.exists?("/var/opt/gitlab/bootstrapped")
 37:    node.set['gitlab']['bootstrap']['enable'] = false
 38:  end
 39:
 40:  directory "/var/opt/gitlab" do
 41:    owner "root"
^[[0m

^[[0m
[2015-03-31T16:20:03-04:00] ERROR: Running exception handlers
[2015-03-31T16:20:03-04:00] ERROR: Exception handlers complete
[2015-03-31T16:20:03-04:00] FATAL: Stacktrace dumped to /opt/gitlab/embedded/cookbooks/cache/chef-stacktrace.out
[2015-03-31T16:20:03-04:00] ERROR: /etc/gitlab/gitlab.rb:37: syntax error, unexpected {, expecting ']'
/etc/gitlab/gitlab.rb:43: syntax error, unexpected ']', expecting end-of-input
[2015-03-31T16:20:03-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
2 comments
  • I would look for what you probably mistyped in that Chef recipe? I see no gitlab errors of any sort.

  • If you look at the lines

    /etc/gitlab/gitlab.rb:37: syntax error, unexpected {, expecting ']'
    /etc/gitlab/gitlab.rb:43: syntax error, unexpected ']', expecting end-of-input^[[0m
    

    You will see that gitlab doesn't like the syntax in my /etc/gitlab/gitlab.rb file. This is an omnibus installer, so I did not create the Chef recipe. There is zero documentation anywhere on how to use multiple oAuth providers at the same time.

1 Answer

Based on:

[2015-03-31T16:20:03-04:00] ERROR: /etc/gitlab/gitlab.rb:37: syntax error, unexpected {, expecting ']'

Think this is most likely just a missing comma after the first provider:

gitlab_rails['omniauth_providers'] = [
    {
      "name" => "github",
      "app_id" => "Removed for Security",
      "app_secret" => "Removed for Security",
      "url" => "https://github.com/",
      "args" => { "scope" => "user:email"}
    },
    {
      "name" => "google_oauth2",
      "app_id" => "Removed for Security",
      "app_secret" => "Removed for Security",
      "args" => { "access_type" => "offline", "approval_prompt" => "" }
    }
]
Have another answer? Share your knowledge.