summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-04-22 12:43:10 -0700
committerStan Hu <stanhu@gmail.com>2016-04-26 21:00:55 -0700
commiteede0323453190440a8d738b5eab0723f54dee65 (patch)
treefd54471c6ed4bf76a0c02404dc3f0918bb3ccdb6 /config
parentc01ff1f54b55a60f7c7473d0d8a429d5cf9c1609 (diff)
downloadgitlab-ce-eede0323453190440a8d738b5eab0723f54dee65.tar.gz
Backport GitHub Enterprise import support from EE
These changes were pulled from GitLab EE to support configuring an alternative API URL than the default https://api.github.com. In addition, the `verify_ssl` flag allows users to disable SSL cert checking. One modification: add a default `args` option if it does not exist to avoid breaking existing configurations.
Diffstat (limited to 'config')
-rw-r--r--config/gitlab.yml.example2
-rw-r--r--config/initializers/1_settings.rb24
2 files changed, 26 insertions, 0 deletions
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index d9c15f81404..2790f1c8a29 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -350,6 +350,8 @@ production: &base
# - { name: 'github',
# app_id: 'YOUR_APP_ID',
# app_secret: 'YOUR_APP_SECRET',
+ # url: "https://github.com/",
+ # verify_ssl: true,
# args: { scope: 'user:email' } }
# - { name: 'bitbucket',
# app_id: 'YOUR_APP_ID',
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 10c25044b75..39641655181 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -140,6 +140,30 @@ Settings.omniauth.cas3['session_duration'] ||= 8.hours
Settings.omniauth['session_tickets'] ||= Settingslogic.new({})
Settings.omniauth.session_tickets['cas3'] = 'ticket'
+# Fill out omniauth-gitlab settings. It is needed for easy set up GHE or GH by just specifying url.
+
+github_default_url = "https://github.com"
+github_settings = Settings.omniauth['providers'].find { |provider| provider["name"] == "github"}
+
+if github_settings
+ # For compatibility with old config files (before 7.8)
+ # where people dont have url in github settings
+ if github_settings['url'].blank?
+ github_settings['url'] = github_default_url
+ end
+
+ github_settings["args"] ||= Settingslogic.new({})
+
+ if github_settings["url"].include?(github_default_url)
+ github_settings["args"]["client_options"] = OmniAuth::Strategies::GitHub.default_options[:client_options]
+ else
+ github_settings["args"]["client_options"] = {
+ "site" => File.join(github_settings["url"], "api/v3"),
+ "authorize_url" => File.join(github_settings["url"], "login/oauth/authorize"),
+ "token_url" => File.join(github_settings["url"], "login/oauth/access_token")
+ }
+ end
+end
Settings['shared'] ||= Settingslogic.new({})
Settings.shared['path'] = File.expand_path(Settings.shared['path'] || "shared", Rails.root)